typeError _ref 未定义

Ant*_*lez 9 javascript mysql node.js reactjs

我只对 javascript 的基本知识进行反应,我在处理 mysql 的服务器中进行查询,连接很好,但返回是我遇到问题的地方,它应该返回带有查询的 JSON,但我发现错误 typeError _ref 未定义 这里是我连接到 API 的函数

callDB(){
    fetch('http://localhost:4000/lista')
    .then((response)=>{
        response.json()
    })
    .then(({data})=>{
        console.log(data);
    })
    .catch((err)=>{console.log(err);});
}
Run Code Online (Sandbox Code Playgroud)

在数据部分是没有任何想法的地方?先谢谢

El *_*mza 2

您需要response.json()在 Promise 处理程序中返回:

callDB(){
    fetch('http://localhost:4000/lista')
    .then((response)=>{
        return response.json()
    })
    .then(({data})=>{
        console.log(data);
    })
    .catch((err)=>{console.log(err);});
}
Run Code Online (Sandbox Code Playgroud)