# Axios crashes the Node.js process when the request fails

> Fix axios crashing your Node.js process when a request fails by adding a .catch() handler to the promise so the rejected request is handled instead.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-02-08 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/axios-crashes-the-nodejs-process-when-the-request-fails/

I had some code using [axios](https://flaviocopes.com/axios/) to make a network request:

```javascript
axios({
  method: 'post',
  url: 'https://...',
  data: JSON.stringify({
		...
  })
})
```

but I noticed that when the request failed for some reason, it crashed the [Node.js](https://flaviocopes.com/book/node/) process.

..until I added `catch()`:

```javascript
axios({
  method: 'post',
  url: 'https://...',
  data: JSON.stringify({
		...
  })
}).catch((err) => {
  console.error(err)
})
```
