嘿,我正在试着让这个mod.io例子工作起来。下面是他们给出的一个卷曲示例
curl -X POST https://api.mod.io/v1/oauth/emailrequest \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'api_key=0d0ba6756d032246f1299f8c01abc424' \
-d 'email=john.snow@westeros.com'
我正尝试将其添加到我的Vue JS应用程序中,但它返回了401错误。有没有人能看出有什么不对劲?
methods: {
loginUser() {
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
}
console.log(this.email) //Works
const data = {
api_key: "0d0ba6756d032246f1299f8c01abc424",
email: this.email
}
axios
.post('https://api.mod.io/v1/oauth/emailrequest', data, {
headers: headers
})
.then(response => {
console.log(response);
})
.catch((error) => {
console.log(error);
})
}
API和电子邮件来自文档,所以请随意尝试一下。This是我最感兴趣的地方
是不是我的本地主机不是SSL?
发布于 2021-07-22 09:09:49
我就知道我快到了..。
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
const data = "api_key=0d0ba6756d032246f1299f8c01abc424&email="+this.email;
axios
.post('https://api.mod.io/v1/oauth/emailrequest', data, {
headers: headers
})
.then(response => {
console.log(response);
})
.catch((error) => {
console.log(error);
})
https://stackoverflow.com/questions/68470214
复制相似问题