Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static getRequest(url) {
- require('es6-promise').polyfill();
- axios({
- method: 'get',
- url: url,
- responseType:'json',
- withCredentials: true
- })
- .then(response => {
- console.log(response.data);
- return response.data;
- })
- .catch(error => {
- if (error.response) {
- // The request was made and the server responded with a status code
- // that falls out of the range of 2xx
- console.log('___________ERROR RESPONSE__________');
- console.log(error.response.data);
- console.log(error.response.status);
- console.log(error.response.headers);
- } else if (error.request) {
- // The request was made but no response was received
- // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
- // http.ClientRequest in node.js
- console.log('_________ERROR REQUEST_______');
- console.log(error.request);
- } else {
- // Something happened in setting up the request that triggered an
- Error
- console.log('Error', error.message);
- }
- console.log('_________ERROR CONFIG_________');
- console.log(error.config);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement