> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/ajax/nexus-http-client/performing-requests.md).

# Performing Requests

Nexus provides familiar methods for HTTP requests.

{% hint style="info" %}
You can either use `async/await` or `.then()...`
{% endhint %}

```javascript
const client = nexus.create({
  baseURL: 'https://api.example.com',
  cacheEnabled: true,
});
```

{% stepper %}
{% step %}

## GET Request (with caching)

```javascript
client.get('/users', { page: 1 })
  .then(response => console.log(response))
  .catch(error => console.error(error));

//or

client.get('/users?page=1')
  .then(response => console.log(response))
  .catch(error => console.error(error));
```

{% endstep %}

{% step %}

## POST Request

```javascript
client.post('/users', { name: 'John Doe', age: 30 })
  .then(response => console.log(response))
  .catch(error => console.error(error));
```

{% endstep %}

{% step %}

## PUT Request

```javascript
client.put('/users/123', { age: 31 }) 
  .then(response => console.log(response)) 
  .catch(error => console.error(error));
```

{% endstep %}

{% step %}

## PATCH Request

```javascript
client.patch('/users/123', { name: 'Jane Doe' }) 
  .then(response => console.log(response)) 
  .catch(error => console.error(error));
```

{% endstep %}

{% step %}

## DELETE Request

```javascript
client.delete('/users/123') 
  .then(response => console.log(response)) 
  .catch(error => console.error(error));
```

{% endstep %}
{% endstepper %}

{% hint style="info" %}
You can either use `async/await` or `.then()...`
{% endhint %}
