We make requests to https://elm-package-cache-psi.vercel.app, and it does not seem to care about accept and user-agent. When sending accept-encoding, it does not respond with a content-encoding.
So we don’t need to set any headers.
node-fetch automatically follows redirects, while https.get does not. We’re not encountering any redirects though.
The old code using node-fetch did not check for status codes. The new code does. So if the server is down you now get a nicer error than a JSON parse syntax error.
The uses of node-fetch were so few and trivial that I took a shot at getting rid of one more dependency!
Notes:
node-fetch automatically sets these headers by default:
While
https.get
by default only setshost
. Tested using https://hookbin.com/.We make requests to https://elm-package-cache-psi.vercel.app, and it does not seem to care about
accept
anduser-agent
. When sendingaccept-encoding
, it does not respond with acontent-encoding
.So we don’t need to set any headers.
node-fetch automatically follows redirects, while
https.get
does not. We’re not encountering any redirects though.The old code using node-fetch did not check for status codes. The new code does. So if the server is down you now get a nicer error than a JSON parse syntax error.