简体   繁体   English

Rest Api 在 Nodejs Express & MySql

[英]Rest Api In Nodejs Express & MySql

在此处输入图像描述

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.嘿,朋友们,我使用 Nodejs Express 和 Mysql 开发了一个 rest API,它在我的本地机器上运行良好,然后我将它托管在 Cpanel 上,现在我正在尝试从中获取数据并将其呈现在我的 React 应用程序上. 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.很好地获取数据部分就像变魔术一样,它甚至在我的控制台中呈现,但是当我 map 我的 React 应用程序上的数据时,它给出了下面的错误,并且只是一个空白的白页。 May you please assist.请你帮忙。

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.如果数据 object 仍然是嵌套的 object(又名 JSON)格式,那么对其使用 .map() 将不起作用,因为 .map() 不是对象的 function。

Try converting data to an array of objects then use.map().尝试将数据转换为对象数组,然后使用 .map()。

You can grab all the values with Object.values and push into an array that you can map您可以使用 Object.values 获取所有值并推入一个数组,您可以 map

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM