# http

<mark style="color:purple;">`http`</mark> `get(`<mark style="color:green;">`website`</mark>, <mark style="color:green;">`function: body, statuscode`</mark>`)` -> <mark style="color:purple;">void</mark>

Retrieves websites body.

| Name       | Type                                         | Description                          |
| ---------- | -------------------------------------------- | ------------------------------------ |
| website    | <mark style="color:green;">`string`</mark>   | Website address.                     |
| function   | <mark style="color:green;">`function`</mark> | Callback function.                   |
| body       | <mark style="color:green;">`string`</mark>   | Data returned by the website.        |
| statuscode | <mark style="color:green;">`number`</mark>   | Status code returned by the website. |

<mark style="color:purple;">`http`</mark> `post(`<mark style="color:green;">`website`</mark>, <mark style="color:green;">`payload`</mark>, <mark style="color:green;">`function: body, statuscode`</mark>`)` -> <mark style="color:purple;">void</mark>

Sends a post to the website.

| Name       | Type                                       | Description                          |
| ---------- | ------------------------------------------ | ------------------------------------ |
| website    | <mark style="color:green;">`string`</mark> | Website address.                     |
| payload    | <mark style="color:green;">`string`</mark> | Data to post.                        |
| body       | <mark style="color:green;">`string`</mark> | Data returned by the website.        |
| statuscode | <mark style="color:green;">`number`</mark> | Status code returned by the website. |

## Example

```lua
http.get("https://cataas.com/cat", function(body, stats)
    if stats == 200 then -- 200 = success, 500 = error
        local filename = "random_cat.jfif"
        file.write(filename, body, "binary")
    end
end)
```
