# HTTP Request Methods

All of the Frisby.js HTTP methods are based on the `fetch()` API standard. Frisby.js offers pre-defined `get`, `post`, `put`, and `del` for convenience and better readability.

If you need to do something custom like send requests through a proxy, you can also use `fetch` method directly with custom options from the `fetch` spec.

## frisby.get(url)

Issues an HTTP GET request.

```javascript
const frisby = require('frisby');

it ('GET should return a status of 200 OK', function () {
  return frisby
    .get('http://api.example.com/posts')
    .expect('status', 200);
});
```

## frisby.post(url, \[params])

Issues an HTTP POST request, with optional provided parameters.

Assumes JSON and sends the header `Content-Type: application/json` by default.

```javascript
const frisby = require('frisby');

it ('POST should return a status of 201 Created', function () {
  return frisby
    .post('http://api.example.com/posts', {
      title: 'My New Blog Post',
      content: '<p>A cool blog post!</p>'
    })
    .expect('status', 201);
});
```

## frisby.put(url, \[params])

Issues an HTTP PUT request, with optional provided parameters. Semantics are the same as `frisby.post()`.

```javascript
const frisby = require('frisby');

it ('POST should return a status of 200 OK', function () {
  return frisby
    .put('http://api.example.com/posts/1', {
      title: 'My Updated Title',
      content: '<p>Some different content actually</p>'
    })
    .expect('status', 200);
});
```

## frisby.del(url)

Issues an HTTP DELETE request.

```javascript
const frisby = require('frisby');

it ('DELETE should return a status of 204 No Content', function () {
  return frisby
    .del('http://api.example.com/posts/1')
    .expect('status', 204);
});
```

## frisby.fetch(url, \[options])

If you need to do something custom, or if for some reason none of the above helper HTTP methods suit your needs, you can use `fetch` directly, which accepts all the same options and parameters as the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) - Frisby.js just passes them through for your request.

```javascript
const frisby = require('frisby');

it ('fetch with POST should return a status of 201 Created', function () {
  return frisby
    .fetch('http://api.example.com/posts', {
      method: 'POST',
      body: JSON.stringify({
        title: 'My Updated Title',
        content: '<p>Some different content actually</p>'
      })
    })
    .expect('status', 201);
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.frisbyjs.com/api-and-usage/http.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
