Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. static getRequest(url) {
  2. require('es6-promise').polyfill();
  3. axios({
  4. method: 'get',
  5. url: url,
  6. responseType:'json',
  7. withCredentials: true
  8. })
  9. .then(response => {
  10. console.log(response.data);
  11.  
  12. return response.data;
  13. })
  14. .catch(error => {
  15. if (error.response) {
  16. // The request was made and the server responded with a status code
  17. // that falls out of the range of 2xx
  18. console.log('___________ERROR RESPONSE__________');
  19. console.log(error.response.data);
  20. console.log(error.response.status);
  21. console.log(error.response.headers);
  22. } else if (error.request) {
  23. // The request was made but no response was received
  24. // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
  25. // http.ClientRequest in node.js
  26. console.log('_________ERROR REQUEST_______');
  27. console.log(error.request);
  28. } else {
  29. // Something happened in setting up the request that triggered an
  30. Error
  31. console.log('Error', error.message);
  32. }
  33. console.log('_________ERROR CONFIG_________');
  34. console.log(error.config);
  35. });
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement