js fetch status of 500

Solutions on MaxInterview for js fetch status of 500 by the best coders in the world

showing results for - "js fetch status of 500"
Marie
26 Sep 2018
1fetch('http://some-site.com/api/some.json')  
2  .then(function(response) {                      // first then()
3      if(response.ok)
4      {
5        return response.text();         
6      }
7
8      throw new Error('Something went wrong.');
9  })  
10  .then(function(text) {                          // second then()
11    console.log('Request successful', text);  
12  })  
13  .catch(function(error) {                        // catch
14    console.log('Request failed', error);
15  });
16
similar questions
queries leading to this page
js fetch status of 500