Advertisement
Guest User

Untitled

a guest
Jan 26th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. export default {
  2. name: 'app',
  3. components: {
  4. Hello
  5. },
  6. created () {
  7. const postData = {
  8. grant_type: 'password',
  9. client_id: 2,
  10. client_secret: 'somesecret',
  11. username: 'my@mail.com',
  12. password: 'password',
  13. scope: ''
  14. }
  15. this.$http.post('http://localhost:8000/oauth/token', postData)
  16. .then(response => {
  17. console.log(response)
  18. const header = {
  19. 'Accept': 'application/json',
  20. 'Authorization': 'Bearer ' + response.body.access_token
  21. }
  22. this.$http.get('http://localhost:8000/api/test', {headers: header})
  23. .then(response => {
  24. console.log(response)
  25. })
  26. })
  27. }
  28. }
  29.  
  30. Uncaught (in promise) TypeError: Cannot read property 'access_token'
  31. of undefined at eval (eval at <anonymous> (app.js:810), <anonymous>:33:51)
  32. (anonymous) @ App.vue?86c0:29
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement