Home > Software design >  Rest Api In Nodejs Express & MySql
Rest Api In Nodejs Express & MySql

Time:03-26

enter image description here

Hey friends, so what happened is I developed a rest API using Nodejs Express and Mysql, It is working fine on my local machine, I then hosted it on Cpanel, now I am trying to fetch data from it and render it on my react app. Well fetching the data part works like magic, its even rendering in my console, but when I map the data on my react app it is giving the error below, and just a blank white page. May you please assist .

CodePudding user response:

If the data object is still in a nested object (aka JSON) format, then using .map() on it won't work, as .map() is not a function for Objects.

Try converting data to an array of objects then use .map().

CodePudding user response:

What is the type of your data variable? Looks like its not an array.

CodePudding user response:

You can grab all the values with Object.values and push into an array that you can map

  • Related