DEV Community

Discussion on: Step by step React, NodejS and MySQL Simple Full Stack Application 2018 (part: 5)

Collapse
 
xiaohan_du profile image
Xiaohan Du

I think my problem is in here: Then use npm install axios for backend and bower install axios for using axios to frontend commands in terminal to access axios and use it., can you add some explanation of where to install for backend and where to install for frontend, and where to start the servers please?

Collapse
 
alivadjid profile image
alivadjid • Edited

Sorry. I had a problem in this lesson. After add CORS,and modified app.js.
For your problem.
"Then use npm install axios for backend"----- I wrote: npm install axios. At the terminal in vusual studio.
"and bower install axios for using axios to frontend commands in terminal to access axios and use it".------Wrote "bower install axios" at GitBash =) After this command must appeare "bower_components" folder in /express-react/backend/client/src
Try this

Collapse
 
xiaohan_du profile image
Xiaohan Du

Appreciate that. I follow what you said: changed to app.get('/users', function(req, res), installed axios in /express-react/backend/client/src and saw bower_components in /express-react/backend/client/src, but still see the same error: TypeError: Cannot read property 'map' of undefined

Thread Thread
 
alivadjid profile image
alivadjid

Ok. what do you see at localhost: 3001? are there information from your SQL?

Thread Thread
 
xiaohan_du profile image
Xiaohan Du

At localhost: 3001 I see Express Welcome to Express, and at localhost: 3000 I see TypeError: Cannot read property 'map' of undefined, this happens at axios.get('/users')
.then((data) => {
console.log(data.data.users);
this.setState({ users: data.data.users });
})
.catch(error => console.log(error));

Thread Thread
 
alivadjid profile image
alivadjid

At localhost 3001 you must see data from your SQL database.
Something like this: "{"users":[{"id":1,"username":"Kris","surname": ..."
Can you send github repo for find issue?

Thread Thread
 
xiaohan_du profile image
Xiaohan Du

Hi alivadjid,
Please see my repo https://github.com/thinkvantagedu/HW10.git
Thank you

Thread Thread
 
xiaohan_du profile image
Xiaohan Du

If I run node server in directory simple-react-mysql, I can see the data from my SQL database in localhost:3000

Thread Thread
 
alivadjid profile image
alivadjid • Edited

well, you shoud to restart lesson 4. From position 2 and install all components from lesson.