needle icon indicating copy to clipboard operation
needle copied to clipboard

About needle('get')

Open ZehuaZhang opened this issue 5 years ago • 4 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

ZehuaZhang avatar May 23 '19 23:05 ZehuaZhang

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

tomas avatar May 24 '19 23:05 tomas

What I wanted to ask is that are both method’s data field all can form into queries when they are get request?

Thanks Zehua


From: Tomás Pollak [email protected] Sent: Friday, May 24, 2019 4:52:48 PM To: tomas/needle Cc: ZehuaZhang; Author Subject: Re: [tomas/needle] About needle('get') (#279)

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/tomas/needle/issues/279?email_source=notifications&email_token=ADX3A7GGIOBUUQC5DK6FDQLPXB5VBA5CNFSM4HPLAFX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGYZJY#issuecomment-495815847, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADX3A7FYCMV2CTKEES3OUDTPXB5VBANCNFSM4HPLAFXQ.

ZehuaZhang avatar May 27 '19 09:05 ZehuaZhang

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 avatar May 27 '19 09:05 tomas

@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.)

mbutcher avatar Jun 14 '19 14:06 mbutcher