Created
February 5, 2019 20:59
-
-
Save nelsonmfinda/d83d2c22fa2b56ac13c13cb544f32ee8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| import axios from 'axios'; | |
| export default { | |
| data () { | |
| return { | |
| email: '' | |
| } | |
| }, | |
| methods: { | |
| onSubmit () { | |
| axios.post( | |
| 'post_url', | |
| {}, | |
| { | |
| withCredentials: true, | |
| baseURL: '', | |
| timeout: 10000, | |
| crossDomain: true, | |
| headers: { | |
| 'Content-Type': 'application/json;charset=UTF-8', | |
| 'Access-Control-Allow-Origin': '*', | |
| 'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,OPTIONS', | |
| 'Access-Control-Allow-Headers': "Content-type,Accept,X-Access-Token,X-Key", | |
| 'X-Requested-With': 'XMLHttpRequest', | |
| }, | |
| auth: { | |
| username: '', | |
| password: '' | |
| } | |
| } | |
| ) | |
| .then(function (response) { | |
| console.log('response is : ' + response.data); | |
| }) | |
| .catch(function (error) { | |
| if (error.response) { | |
| console.log(error.response.headers); | |
| } | |
| else if (error.request) { | |
| console.log(error.request); | |
| } | |
| else { | |
| console.log(error.message); | |
| } | |
| console.log(error.config); | |
| }) | |
| } | |
| } | |
| } | |
| </script> | |
| <template> | |
| </template> | |
| <style> | |
| </style> |
Você recebi algum token?
antes do Axios, vamos deixar uma instrução Global...
import axios from 'axios'
axios.defaults.headers.post['Content-Type'] = 'application/json'
Author
@acidiney Sim, recebi um token
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vamos começar eliminando o desnecessário isso pode desaparecer
{ withCredentials: true, baseURL: '', timeout: 10000, crossDomain: true, headers: { 'Content-Type': 'application/json;charset=UTF-8', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,OPTIONS', 'Access-Control-Allow-Headers': "Content-type,Accept,X-Access-Token,X-Key", 'X-Requested-With': 'XMLHttpRequest', }, auth: { username: '', password: '' }