Hey I'm trying to get this mod.io example working. Here is an example curl they give
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'
I am trying to add that to my Vue JS app but it returns a 401 error. Can anyone see anything wrong?
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);
})
}
The API and email are from the docs so feel free to have a try with it. This is where i am struck
Is it possibly my localhost not being SSL?
I knew I was close....
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);
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.