> For the complete documentation index, see [llms.txt](https://docs.trysavvy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trysavvy.com/other-useful-docs/work-in-progress/pending/work-in-progress-how-to-fetch-safely-from-savvy.md).

# Work in Progress: How to Fetch Safely from Savvy

{% hint style="info" %}
Why can't I just do a regular fetch? Two main reasons:

* Fetching from the Front-End exposes private information like API keys. An experienced developer could retrieve that token or secret key and access more information than what you wanted to share.
* Some APIs don't allow fetch requests from the Front-End due to CORS
  {% endhint %}

### Step 1: Copy and Paste

* Copy this code and paste it in the Computed Field, Custom Data Output, or Custom Code for Button where you need it to fetch. The secure key can be in different formats inside the header -it will not always be "Authorization: Bearer {{key}}"

```
  return fetch(`https://savvy-api-proxy-secure.heysavvy.workers.dev/?url=${encodeURIComponent('https://api.example-address.io/api/v2')}`, {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {{group_name-service-key_type}}'
      },
      body: JSON.stringify(data)
    })
    .then(response => response.json())
    .then(response => console.log('response', response))
```

### Step 2: Change the URL

* Change the URL inside of the `encodeURIComponent` function to the actual URL where you're going to be fetching from

### Step 3: Generate a Key for the Key

* Send your key to a Savvy Engineer, they will save it and give you a different key for you to paste in line 6 instead of `group_name-service-key_type`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.trysavvy.com/other-useful-docs/work-in-progress/pending/work-in-progress-how-to-fetch-safely-from-savvy.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
