tomas / needle

Nimble, streamable HTTP client for Node.js. With proxy, iconv, cookie, deflate & multipart support.

Home Page:https://www.npmjs.com/package/needle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About needle('get')

ZehuaZhang opened this issue · comments

Does those two function works as same, except the return?

needle('get', url, data) // could this data form into queries, since I want to use promise

needle.request('get', url, data) // this can form data into queries

The first version returns a Promise. The second one returns a readable stream.

If you're making a GET request, then yes, data object is transformed into a query string and appended to the URL, unless the json option is set to true.

@tomas Has the issue of GET / Promise requests been resolved where data is not being expected? (See #262 ) I know it was opened quite some time ago, and in the meantime it would seem that there is a significant difference between needle('get') and needle.request('get').

(I have been running into the same problem as #262, which is how I came upon this newer thread.)