Api TypeError:无法构造';标题';:无效名称
我正在尝试执行get请求以从API获取所有订单,但我遇到了下一个错误:TypeError:client.js?06a0:96 TypeError:构造“Headers”失败:名称无效。我的代码是:Api TypeError:无法构造';标题';:无效名称,api,vue.js,get,http-headers,typeerror,Api,Vue.js,Get,Http Headers,Typeerror,我正在尝试执行get请求以从API获取所有订单,但我遇到了下一个错误:TypeError:client.js?06a0:96 TypeError:构造“Headers”失败:名称无效。我的代码是: const myHeaders = new Headers({ "content-type" : "application/x-www-form-urlencoded", "headers" : "Acce
const myHeaders = new Headers({
"content-type" : "application/x-www-form-urlencoded",
"headers" : "Access-Control-Allow-Origin', '*",
"Access-Control-Allow-Headers": "Origin, X-Requested-With",
"Authorization " : "Bearer, mytoken"
});
const getSalesUrl = "myurl"
fetch(getSalesUrl, myHeaders)
.then(response => response.json())
.then(json => console.log(json))
}, `
I don't know what i'am doing wrong can any one tell me?
我认为您不需要用fetch库实例化头,这应该足够了
const myHeaders={
“内容类型”:“应用程序/x-www-form-urlencoded”,
“头文件”:“访问控制允许源文件”、“*”,
“访问控制允许标头”:“来源,X请求,带”,
“授权”:“持票人,我的代币”
};
hey感谢您的回复,现在我收到以下错误:未捕获(承诺中)类型错误:未能在“窗口”上执行“获取”:提供的值不是类型(序列或记录)。我不知道您是否知道这可能是什么问题?