Skip to content

Tag: javascript

Fetch API: how to determine if an error is a network error

So I have some code like this: Where transform can throw some of its own errors. I’m try to catch for network errors from the fetch API. My question is how do I implement isNetworkError that works across browsers? Note: that this should only return true if the network is offline. It seems like both chro…

Keep window ratio in electronjs

How can I keep the window width and height aspect ratio in electron? For example, a square shape that can be resized by the user. Answer There’s a win.setAspectRatio API for the BrowserWindow. Note that it’s currently only available on macOS on the latest stable (Electron 8.2.1), but should be ava…

pdf2json parse error in node js application

I am having trouble converting pdf to json format using pdf2json. I want to convert a pdf file into json format using the pdf2json library via nodejs. However, there was no json file in the directory I specified for json, and it did not expire when I put an empty json file. When I run my code in debug mode,