---
# System prepended metadata

title: Testing your API

---

# Testing your API

You can start by pasting these functions into the chrome console.

```js
function get(url) {
    return fetch(`http://localhost:9393/${url}`, {
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        }
    })
        .then(res => res.json())
        .then(console.log)
}

function post(url, body) {
    return fetch(`http://localhost:9393/${url}`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        },
        body: JSON.stringify(body)
    })
        .then(res => res.json())
        .then(console.log)
}

function patch(url, body) {
    return fetch(`http://localhost:9393/${url}`, {
        method: 'PATCH',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        },
        body: JSON.stringify(body)
    })
        .then(res => res.json())
        .then(console.log)
}

function apiDelete(url) {
    return fetch(`http://localhost:9393/${url}`, {
        method: 'DELETE',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        }
    })
        .then(res => res.json())
        .then(console.log)
}
```

## Examples

```js
get("/doctors")
```

```js
post("/new_doctor", {
    name: "Dr. Suess",
    specialization: "Pediatric Imagination"
})
```

```js
patch("/doctors/1", {
    name: "Dr. Drew Pinsky"
})
```

```js
delete("/doctors/1")
```

These function calls will hit your API at the specified endpoint and return a promise for a JSON response that will be logged to the console when the promise resolves. You can check the server logs in your shotgun terminal and the Sqlite Explorer dev tools to get a sense of how things are going while you work.