nodejs+微信小程序上传图片提示
Unexpected token < in JSON at position 0
uploadImg() {
let { imgList } = this.data;
wx.chooseMedia({
count: 6 - imgList.length,
mediaType: ['image'],
sourceType: ['album', 'camera'],
success: (res) => {
const { tempFiles } = res;
console.log(tempFiles);
tempFiles.forEach((item, index) => {
wx.uploadFile({
url: 'http://localhost:3001/uploadImg',
filePath: item.tempFilePath,
name: 'file',
success: (res) => {
const { data } = res;
let { path } = JSON.parse(data)[0];
console.log(path);
let _path = `http://localhost:3001/${path}`;
console.log(_path);
imgList.unshift(_path);
this.setData({
imgList
})
// const data = res.data
//do something
},
fail: (err) => {
console.log(err);
}
})
})
}
})
},
app.post("/uploadImg",upload.array('file',6),(req,res)=>{
res.send(req.files)//这个接口的意思是调用定义好的实体upload上传图片,一次性上传的图片次数最大为10张,上传完成后会向接口返回存放地址files
})
这个要怎么解决,一直卡在这里了