fullstackreact / food-lookup-demo

A demonstration of using `create-react-app` with a server
MIT License
1.19k stars 373 forks source link

npm start produces page with no data #50

Open JDWong-wag opened 6 years ago

JDWong-wag commented 6 years ago

Followed the instructions, no changes made, empty console:

screen shot 2018-03-22 at 6 53 03 pm
I-keep-trying commented 6 years ago

I'm having the same issue - seems as if there is more configuration needed. In case you are wondering the obvious, yes, I did enter some values into the search box, but nothing happens. I made sure the values were actually in the data as well.

The lookup server is working fine. A test query http://localhost:3001/api/food?q=cheeseburger returned expected results:

[{"carbohydrate_g":28.03,"protein_g":16.51,"fat_g":"13.54","kcal":308,"description":"Fast` foods, cheeseburger; single, reg patty; pln"},
{"carbohydrate_g":25.46,"protein_g":13.49,"fat_g":"12.20","kcal":270,"description":"Fast foods, cheeseburger; single, reg patty, w/ condmnt"}....]

On http://localhost:3000/ there is an error: Uncaught (in promise) Error: HTTP Error Not Found on Client.js, line 15, const error = new Error('HTTP Error ${response.statusText}');.

I didn't change anything in any of the code. I just cloned the repo and pretty much everything worked except this part.

I-keep-trying commented 6 years ago

OK, I have an update.

For me, the trouble actually started in the instructions, because there was this whole deleting and then replacing the client directory, and the git checkout master -- {client/src,client/semantic,client/semantic.json} syntax simply did not work for me, for some reason - I'm on a Windows machine, using the terminal inside Visual Studio Code, everything is up to date, and 99.9% of the time, I don't have syntax issues with CLI commands; however, I'm not very experienced with git, and this particular command refused to cooperate.

So, after much googling, trying to figure out exactly what that line was supposed to be accomplishing, without any success whatsoever, I decided to just delete my entire project and start over, this time skipping the rm client step. That got me into trouble, which I only fixed after noticing that the package.json in the food-lookup-demo repo was quite different than the one I ended up with, (it did not have semantic-ui, babel-plugin, or enzyme, among other things) making it match, and then running npm i again.

Now, the React app search works as expected! :-D