I'm trying to create a new user on my forums (Flarum) from a external script using VueJS + Axios, but, I keep getting 405 error.
Log:
/api/users 405 (Method Not Allowed)
#:1 Failed to load /api/users: Response for preflight has invalid HTTP status code 405.
Code i'm using
axios.post(forumAPI, {
data: {
attributes: {
username: this.data.attributes.username,
password: this.data.attributes.password,
email: this.data.attributes.email,
}
},
headers: {
'Authorization': 'Token XXXXX',
'Content-Type': 'application/vnd.api+json'
},
})
.then(function (response) {
store.dispatch('login', this.data.attributes).then(() => {
this.$router.push(this.$route.query.redirect || '/dev');
this.loading = false;
this.hideModal();
})
})
.catch(function (error) {
console.log(error);
_this.loading = false;
})
I need post a json like this one:
{"data":
{ "attributes":
{
"username":"mickey",
"email":"mickey@disney.com",
"password":"hellokitty"
}
}
}
I know theres something wrong with my sintax, but, I can't figure it out.
Any solutions around here?
Thanks!