I'm building out the Official React Tutorial, inside the official create-react-app build environment. It's almost all working, except for one problem:
The JQuery POST is returning a 404 error, while GET is working. This is on the same URL. It means I can't get the final step in the tutorial working: saving a comment to the JSON file....
I think it's in the server setup under create-react-app. Anyone have experience getting this working in the create-react-app environment?
https://github.com/seanrasmussen/react-tutorial-in-create-react-app
To be clear, this tutorial predates Create React App by a few years.
It has not been updated to work with it.
The “server” referenced there has nothing in common with the server used by Create React App. The server from the tutorial is implemented in different languages here and all it does is read and write JSON. The server used by Create React App has no knowledge about any JSON files, and it exists only to serve static assets in development.
Just doing a POST request to a .json file won’t cause a write. The fact that GET worked is likely a coincidence. You need an actual API server implementation that will write it:
In order to start this tutorial, we're going to require a running server. This will serve purely as an API endpoint which we'll use for getting and saving data. In order to make this as easy as possible, we've created a simple server in a number of scripting languages that does exactly what we need it to do. You can view the source or download a zip file containing everything needed to get started.
To make that tutorial work with Create React App, you can launch the server _described in the tutorial_ on some port, and then make calls _to that server_ from your app’s code. I hope this makes sense. We intend to amend the documentation in the future to make it clearer.
(Also, that GET is working is not very good. There’s probably some default setting in WebpackDevServer that we need to disable because this is just confusing.)
OK thanks...There are a lot of moving parts and I wasn't sure where it was breaking down.
Let’s keep it open because we definitely want to update the tutorial to play well with this.
Think of “the server” in that tutorial as the backend. It has no real relation to your React app. So you can put it in some different folder, keep comments.json there, and $.ajax to the port where you run that server.
Yes, in another create-react-app sandbox that I made I easily connected to a separate wordpress rest api (using Axios)...
I wanted to do the Official Comments Tutorial, more like I would build a real project: using ES6 classes, and separating components into separate files etc... Which is what I did in my repo. I think it would be great to have a version of the tutorial for create-react-app, that does it that way.
Agreed!
I'm currently writing up a tutorial that interacts with the Github API (I know a tad boring these days, however requires no auth). I will be throwing in redux and all the other toys individuals seem to be asking for as a second parter. If this is of interest, I'll gladly let anyone do what they would like with it once it is complete.
If I may plug my stuff, I've finished writing this, coming very very soon!
Starts with the basics of React and then, using create-react-app, builds an actual app that interacts with an API. (also covers redux and immutable based on the request of the client)
Awesome! I can't wait to check them out.
On Aug 11, 2016 4:23 AM, "Jonny Buchanan" [email protected] wrote:
I wanted to do the Official Comments Tutorial, more like I would build a
real project: using ES6 classes, and separating components into separate
files etc... Which is what I did in my repo. I think it would be great to
have a version of the tutorial for create-react-app, that does it that way.I've done this for nwb if you want a quick starting point, the features
used should be compatible with create-react-app's default config:https://github.com/insin/nwb-react-tutorial
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebookincubator/create-react-app/issues/390#issuecomment-239112040,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACifEybbwIqf8NjKHX3VR_0qUevT9Kgks5qeuoWgaJpZM4JeaLS
.
Updating tutorial won't happen until CRA 1.0 so I'll close as non actionable for now.