发送请求没有发生浏览器跨域报错,但是response啥都没有返回?
onSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
fetch(`https://www.dianzhentan.com/api/items/${this.form.appkey}/?shopid=${this.form.shopId}&d=${this.form.date ? this.form.date : ''}`, {
method: "GET",
mode: "no-cors",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
}).then(function (res) {
console.log("Response succeeded?", JSON.stringify(res.ok));
console.log(JSON.stringify(res));
}).catch(function (e) {
console.log("fetch fail", JSON.stringify(params));
});
} else {
console.log('error submit!!');
return false;
}
});
}
更新-----------------------------------------------------------
在火狐上操作就可以返回数据,谷歌浏览器却不行是什么原因?
1.确认接口是否正常(可以替换一个好的的接口测试,是否返回)
2.可以在控制台-network里 看下是否还在请求中(确认请求是否完成)
3.确认没有其他报错影响返回值的展示