sheaivey / react-axios

Axios Components for React with child function callback
MIT License
180 stars 20 forks source link

Data parameters not being sent #17

Closed nolawnchairs closed 7 years ago

nolawnchairs commented 7 years ago

Version 1.0.3 installed via NPM

        <Post url={this.url}
                 data={this.requestVars}
                 onSuccess={(response) => { this.onSuccess(response) }}
                 onLoading={this.onLoading}
                 onError={(error) => { this.onError(error) }} />

this.requestVars is a valid object, so I tried hard-coding:

        <Post url={this.url}
                 data={ { foo: "bar", baz: 42 } }
                 onSuccess={(response) => { this.onSuccess(response) }}
                 onLoading={this.onLoading}
                 onError={(error) => { this.onError(error) }} />

That also sent no POST parameters.

davingreen commented 7 years ago

Also having this issue with Request component.

sheaivey commented 7 years ago

I can not recreate your issue. Looking at the browser post in chrome shows that the post is in fact sending the request body data. I tried with both examples.

Are you sure your server is set up to receive request-body? (For a server running Express it would be 'body-parser' https://expressjs.com/en/resources/middleware/body-parser.html) screen shot 2017-08-16 at 9 55 24 am

davingreen commented 7 years ago

@mweiczorek @sheaivey I stringified the data params with querystring and it appears to be working. Using this on a simple client app without any middleware. Had to do the same thing with straight axios calls too: https://github.com/mzabriskie/axios#nodejs

sheaivey commented 7 years ago

@davingreen since you are not using the Express body-parse middleware you will not have access to post body. Querystring may be a work around but you should look into getting the getting post body working. I suggest using Postman for testing your server requests outside of your app.

I am going to close this issue since react-axios is functioning properly from he client side and is confirmed sending the request payload.