使用vue-resource 发送一个get请求,响应数据是文本,却接收到的数据是blob类型。请问怎么破?
node.js 服务器代码:
router.get('/',function (req, res, next) {
var data = querystring.parse(url.parse(req.url).query);
res.sendfile("./public/song/"+data.lyric,'utf8');
})
vue-resource 代码:
this.$http.get(url)
.then(function (res) {
console.log(res.body);
})
响应内容:
Sorry, I’m not very familiar with express and vue-resource
Try to change the server code and specify the header
If I remember correctly, the res of vue-resource has the text attribute
It is recommended to use superagent or axios
If I remember correctly, res.data is the response data