In api.js you're building the url path using the path library. This is an issue because it was meant for file system paths.
The resulting path on a unix machine is:
https:/api.coconut.co/v2/jobs which kinda works since https.request is smart enough to not have issue with only one / at https.
BUT, on Windows the result is:
https:\\api.coconut.co\\v2\\jobs this doesn't work, https.request sees this invalid url and tries it's best to convert it and it ends up being https://api.coconut.co//v2/jobs. Now the server since it receives this invalid url it responds with 400 Bad Request.
A good fix would be to use something like the URL object to build the URL or somethign else.
Warning
path is only meant for filesystem paths.
In api.js you're building the url path using the path library. This is an issue because it was meant for file system paths.
The resulting path on a unix machine is:
https:/api.coconut.co/v2/jobswhich kinda works sincehttps.requestis smart enough to not have issue with only one/at https.BUT, on Windows the result is:
https:\\api.coconut.co\\v2\\jobsthis doesn't work,https.requestsees this invalid url and tries it's best to convert it and it ends up beinghttps://api.coconut.co//v2/jobs. Now the server since it receives this invalid url it responds with 400 Bad Request.A good fix would be to use something like the
URLobject to build the URL or somethign else.