Does axios throw for bad http status by default
- User
Does axios throw for bad http status by default
Assistant
No, by default, Axios does not throw an error for bad HTTP status codes. Instead, it returns a promise that resolves to the response object, which contains information about the status code, headers, and body of the response.
If you want to throw an error for bad HTTP status codes, you can use the
validateStatusoption in the Axios configuration object. For example:axios.create({ validateStatus: true }) .get('https://example.com/api/data') .then(response => { // handle response data }) .catch(error => { // handle error });In this example, if the response status code is not in the range of 200-299, Axios will throw an error.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.