Tag Archives: vue

Reading ntfy stream in vue3-ts page using axios

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); } })

vue: navigator.mediaDevices is undefined

If you are using internal IPs e.g. 192.168.0.300 etc for development, you are likely to encounter this error when dealing with media devices.

Assuming that you are not using localhost for development for a reason, you can do either of the following

  1. In Firefox you can enable the following two options described in https://stackoverflow.com/a/66605018/1805129. Go to about:config
    set to true media.devices.insecure.enabled and media.getusermedia.insecure.enabled

90c8821922ca484ba9ad755c39c9adbe -- <code>about:config</code> options in firefox” title=”” class=”aligncenter” /></a></p>
<ol>
<li>You can use service like <code>ngrok</code> or https://serveo.net/ to temporarily get https address. I learnt about these two services in the README file of https://www.npmjs.com/package/vue-qrcode-reader.</li>
</ol>
					</div><!-- .entry-content -->
		
		<footer class= This entry was posted in Notes and tagged , , , , , on by .