DEV Community

Need help integrating stripe in react; getting 404

Christy on January 28, 2019

I'm learning how to integrate Stripe into React & Express. I'm getting a 404 error. Also, when I try to console.log the req.body, nothing appea...
Collapse
 
deadlybyte profile image
Carl Saunders

Usually this issue is due to the order of the middleware being configured. The app.use(bodyParser.text()) has to be configured before the routes are declared.

I've created a glitch project to demonstrate how the code could be implemented.

Good luck 🀞 with getting the issue sorted.

Collapse
 
jbull328 profile image
John Bull

I find I struggle with fetch requests, and generally reach for Axios. Something about the syntax doesn't compute for me. Might be worth a try.
medium.com/@thejasonfile/fetch-vs-...

Here is a quick overview of the differences I found.

The examples within do a fetch.then passing the results to another function. Maybe that is it.

Collapse
 
christycakes profile image
Christy • Edited

After going through a whole troubleshoot checklist, including suggestions below (thank you), I went back to the beginning and thought about the error message 404. I looked at my url and the stripe documentation again. Changing

http://127.0.0.1:3000/api/charge

to

/charge

solved it. However, I'm not sure why. My other fetch requests on this app use the longer version. Can anyone explain?