The following worked for me
onMounted(async () => {
refreshMetricInterval = setInterval((_) => {
fetchData()
}, C.DEFAULT_POLL_INTERVAL_SEC * 1000)
// Subscribe to ntfy.
const ntfy = await axios.get('<https://ntfy.sh/mytopic/json>', {
headers: {
Authorization: 'Bearer yout_token',
Accept: 'text/event-stream',
},
responseType: 'stream',
adapter: 'fetch',
});
// This doesn't work. We are using fetch API and the below solutions work.s
//
// ```
// console.debug('axa1', ntfy.data)
// ntfy.data.on('message', (data) => {
// console.debug(444, data);
// });
// ```
for await (const data of ntfy.data) {
const json = JSON.parse(new TextDecoder().decode(data));
console.debug('Got line from ntfy', json);
}
})