CopyPastor

Detecting plagiarism made easy.

Score: 0.8169047832489014; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2022-07-21
by Deepak Singh

Original Post

Original - Posted on 2018-05-31
by Sagar



            
Present in both answers; Present only in the new answer; Present only in the old answer;

handle **API error with Promise catch method**
let url = `` axios.get(url) .then((response) => { // Success }) .catch((error) => { // 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.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); } else { // Something happened in setting up the request that triggered an Error console.log('Error', error.message); } console.log(error.config); });
Better way to handle **API error with Promise catch method***.

axios.get(people) .then((response) => { // Success }) .catch((error) => { // 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.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); } else { // Something happened in setting up the request that triggered an Error console.log('Error', error.message); } console.log(error.config); });

        
Present in both answers; Present only in the new answer; Present only in the old answer;