【发布时间】:2021-07-21 13:16:22
【问题描述】:
嘿,我正在尝试让这个 mod.io 示例正常工作。这是他们给出的示例 curl
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 吗?
【问题讨论】:
标签: javascript vue.js post http-post