trae
trae copied to clipboard
Headers is an empty object
I am using trae in two separate Vue projects and I had the same issue on both, when I use trae to get information from an api I the data I receive is ok, but headers is an empty object. I did a basic configuration so I believe there must not be any problem.
Here is the code and the response from the server:
api-service.js
import trae from 'trae'
const apiService = trae.create({
baseUrl: configService.apiUrl
})
export default apiService
Login.vue
import apiService from '@/services/api-service'
export default {
name: 'Login',
data () {
return {
email: '',
password: ''
}
},
methods: {
processLogin () {
apiService.post('auth/login', {
user: {
email: this.email,
password: this.password
}
}).then(res => {
console.log(res)
}).catch(err => {
console.log(err)
})
}
}
}
Result from trae:
{
"config": {
"headers": {
"Content-Type": "application\/json"
},
"post": {
"headers": {
"Content-Type": "application\/json"
}
},
"body": "{\"user\":{\"email\":\"[email protected]\",\"password\":\"secret\"}}",
"method": "POST",
"url": "http:\/\/localhost:3000\/auth\/login"
},
"headers": {
},
"status": 200,
"statusText": "OK",
"data": {
"id": 1,
"email": "[email protected]",
"created_at": "2019-01-11T20:41:11.645Z",
"updated_at": "2019-01-11T20:41:11.645Z"
}
}
Response from server:
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
Access-Control-Allow-Origin: http://localhost:8080
Access-Control-Expose-Headers:
Access-Control-Max-Age: 1728000
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwic2NwIjoidXNlciIsImF1ZCI6bnVsbCwiaWF0IjoxNTQ3NTc5NDgwLCJleHAiOjE1NDc2NjU4ODAsImp0aSI6IjlkYWVjYWIwLWY0ZjMtNGQzNi1iNDlhLTMzODYxNTAyNGNhNyJ9.27lWYyy6tt6Jtc4DnM5KaNs2V979PgEAO0uiMa0RJ9s
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
ETag: W/"a68268827029daa20904201f87327aa7"
Transfer-Encoding: chunked
Vary: Origin
X-Request-Id: 309b1d86-23ca-4252-93a1-630f0ac6a415
X-Runtime: 0.200145
I want to receive the Authorization token inside the response headers to be used in future requests, but trae only gives me an empty object.
Same problem
Thanks for reporting.
Could you create a sandbox with reproduced case? (You can use the Vue template). This will be very helpful for us to figure out what's wrong.