Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to request-promise-native [closed]

I was looking for modern modules that implement basic HTTP methods such as GET, POST in Node.js.

I guess the most popular is request. The async/await version of it is called request-promise-native.

Recently I learned that these modules are being deprecated. So, what modern alternatives can I use that are built on the async/await paradigm?

like image 344
Sergey Avdeev Avatar asked Feb 21 '20 08:02

Sergey Avdeev


2 Answers

Got is pretty sweet.

"Got was created because the popular request package is bloated. Furthermore, Got is fully written in TypeScript and actively maintained." - https://www.npmjs.com/package/got#faq

enter image description here

like image 197
Yarin Avatar answered Sep 18 '22 15:09

Yarin


I'd strongly suggest using node-fetch. It is based on the fetch API in modern browsers. Not only is it promise-based it also has an actual standard behind it.

The only reason you wouldn't use fetch is if you don't like the API. Then I'd suggest using something cross-platform like axios or superagent.

I personally find using the same API on the server and browser eases maintainability and offers potential for code reuse.

like image 21
slebetman Avatar answered Sep 20 '22 15:09

slebetman