Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headers is an empty object #183

Open
rodolfomg opened this issue Jan 15, 2019 · 2 comments
Open

Headers is an empty object #183

rodolfomg opened this issue Jan 15, 2019 · 2 comments
Milestone

Comments

@rodolfomg
Copy link

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\":\"rodo@test.com\",\"password\":\"secret\"}}",
    "method": "POST",
    "url": "http:\/\/localhost:3000\/auth\/login"
  },
  "headers": {
    
  },
  "status": 200,
  "statusText": "OK",
  "data": {
    "id": 1,
    "email": "rodo@test.com",
    "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.

@jlozano254
Copy link

Same problem

@gillchristian
Copy link
Member

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.

@gillchristian gillchristian added this to the 2.0 milestone Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants