Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Shift doesn't work #2

Closed
adv0r opened this issue Mar 15, 2016 · 6 comments
Closed

Shift doesn't work #2

adv0r opened this issue Mar 15, 2016 · 6 comments

Comments

@adv0r
Copy link

adv0r commented Mar 15, 2016

Is this library outdated ?

I am using the dist js file and cannot shift.

the post method is actually calling a get :

function post (url, data, callback) {
  xhr({ method: 'GET', url: url, json: true, timeout: 30000, data: data }, function (err, resp, body) {

I changed to method:'POST' and now got a json error Invalid or poorly formed JSON .

@jprichardson
Copy link
Member

Is this library outdated ?

No, I use it daily in http://www.exodus.io/

the post method is actually calling a get :

Ah, ok. I don't use the browser http transport personally. That may be why. Are you using npm by chance?

@adv0r
Copy link
Author

adv0r commented Mar 15, 2016

Are you using npm by chance?

Nope, I am using the file you compiled with browserify I guess.

@jprichardson
Copy link
Member

Thanks for the catch on 'GET' vs 'POST'... change (

xhr({ method: 'GET', url: url, json: true, timeout: 30000, data: data }, function (err, resp, body) {
)

xhr({ method: 'GET', url: url, json: true, timeout: 30000, data: data }, function (err, resp, body) {

to

xhr({ method: 'POST', url: url, json: true, timeout: 30000, body: JSON.stringify(data) }, function (err, resp, body) {

Note the changes: 'POST', data => body and JSON.stringify.

Let me know if that works.

@jprichardson
Copy link
Member

Did this work for you?

@adv0r
Copy link
Author

adv0r commented Mar 19, 2016

Thanks, I gave up and decided to write my own library, I only needed one
method so it didn't make sense to load an entire library.
Thanks

On Sat, Mar 19, 2016 at 10:32 AM, JP Richardson [email protected]
wrote:

Did this work for you?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#2 (comment)

❝ Nicolò Paternoster
☎ +34 603.678.719
ଭ adva.io

@fanatid
Copy link
Contributor

fanatid commented Mar 20, 2016

@jprichardson I think that right request should be:

xhr({ method: 'POST', url: url, json: data, timeout: 30000 }, function (err, resp, body) {

because https://github.com/Raynos/xhr/blob/341450ea3cf21405df2349ea2d0df309d896e9d3/index.js#L162

and GET:

xhr({ method: 'GET', url: url, json: undefined, timeout: 30000 }, function (err, resp, body) {

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants