下面的代码总是返回下面的有线对象
{"_:0","_V:0","_W:null","_X:null}
作为回应.
这是我的密码
getData = () => {
fetch('http://192.168.64.1:3000/getAll',{
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
.then((response) => {
console.log('Response:')
console.log(response.json())
console.info('=================================')
})
.catch(err => console.error(err));
}
componentDidMount(){
this.getData();
}
我使用node、express、Mysql作为后端,使用react-native 前端
我的后端代码在这里
app.get('/getAll',(req,res) => {
console.log('getAll method Called');
con.query('select * from dummy',(err,results,fields) => {
if(err) throw err;
console.log('Response');
console.log(results);
res.send(results);
});
});
上面的代码在控制台中给出了正确的输出,但fetch API不正确.
我找不到解决问题的办法.提前谢谢.