我在快递服务器上有一个React应用程序。我正在使用fetch从客户端向服务器发出GET请求,当我在chrome上时响应作为Content-Type text / html返回,而在Postman中尝试时则返回为application / json。我想要将其作为JSON。邮递员回应:从按钮调用时,Chrome中的“网络”标签:我尝试更改快递请求中的内容类型。app.get('/spotify/search-track', (req,res) => { spotify.searchTrack(req.query.name).then(function(result) { res.setHeader("Content-Type", "application/json"); res.send(result); });});响应GET请求:fetch('/api/spotify/search-tracks?name=' + val, { method: "GET", data: null, headers : { "Accept": "application/json" }}).then(response => response.json()).then(data => console.log(data));我也在Chrome上收到此错误-可能是因为<来自HTML。
添加回答
举报
0/150
提交
取消