Skip to content

Instantly share code, notes, and snippets.

View jonahharris's full-sized avatar

Jonah H. Harris jonahharris

View GitHub Profile
@ktheory
ktheory / Readme.md
Last active January 20, 2024 15:41
Easily make HTTPS requests that return promises w/ nodejs

Javascript request yak shave

I wanted to easily make HTTP requests (both GET & POST) with a simple interface that returns promises.

The popular request & request-promises package are good, but I wanted to figure out how to do it w/out using external dependencies.

The key features are:

  • the ability to set a timeout
  • non-200 responses are considered errors that reject the promise.
  • any errors at the TCP socker/DNS level reject the promise.