---
title: fetch
summary: Fetch resources from backends.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/fn.fetch/
---

**Kind:** Function  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2188

```javascript
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
```

Fetch resources from backends.

**Note**: Fastly Compute requires all outgoing requests to go to a predefined
[backend](https://developer.fastly.com/reference/glossary#term-backend), passed in
via the [backend](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/interface.RequestInit/) property on the `init` object.

**Note**: Can only be used when processing requests, not during build-time initialization.

**See also**

- [fetch on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch)

**Parameters**

- `input`: `RequestInfo | URL`
- `init`: `RequestInit` (optional) — - An object containing settings to apply to the request

**Returns**

`Promise<Response>`
