---
url: /process-functions/web-get.md
description: Sends an HTTP GET request to a URL.
---

# web.get

Sends an HTTP GET request to a URL.

```js
web.get(url, headers, base64Body)
```

## Parameters

| Parameter | Type | Description |
|---|---|---|
| `url` | `string` | The URL to send the request to. |
| `headers` | `object` | Optional. The request headers, keyed by header name. |
| `base64Body` | `boolean` | Optional. `true` to always return the response body base64-encoded. Defaults to `false`. |

## Returns

The response:

* `status` (number): the HTTP status code, or `0` when no response was received.
* `headers` (array): the response headers, each an object with one key/value pair.
* `body` (string): the response body.
* `error` (string): why the request failed, when no response was received.

::: info Binary responses
Common binary types, such as images, PDFs and audio, are detected and returned base64-encoded. To save a file, use [web.download](/process-functions/web-download).
:::

::: tip Status and errors
A `4xx` or `5xx` status means the server received the request and returned an error. See [HTTP status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status).

`error` is only set when the request fails before a response comes back. `status` is then usually `0`. This can happen when:

* the URL is invalid or malformed.
* the connection or response times out.
* the network fails, such as a lost connection, a DNS problem, an SSL validation error or a blocked request.
* the server drops or rejects the request without responding.
  :::

## Examples

```js
const response = web.get("https://api.example.com/data", { "Authorization": "Bearer your_token" });
console.log(response.status);    // 200
console.log(response.headers);   // Array of headers
console.log(response.body);      // Response body as a string or base64-encoded string
```

```js
const response = web.get("https://api.example.com/data");

// Check if the response status code is in the success range (between 200 and 299, inclusive).
if (response.status >= 200 && response.status < 300) {
    console.log("Request succeeded.");
    console.log(response.body);
} else if (response.error) {
    // An error occurred while sending the request (e.g., network error, timeout, etc.).
    console.log("Error occurred while sending the request: " + response.error);
} else {
    // The request failed with a non-success status code.
    console.log("Request failed with status code: " + response.status);
    console.log(response.body);
}
```

## Related

* [web.post](/process-functions/web-post)
* [web.download](/process-functions/web-download)
* [web.setConnectionTimeout](/process-functions/web-setconnectiontimeout)
