Skip to content

Commit 7f881ff

Browse files
[excel] (External calls) Add fetch note (#786)
* [excel] (External calls) Add fetch note * Update docs/develop/external-calls.md --------- Co-authored-by: Linda Cannon <[email protected]>
1 parent bba5998 commit 7f881ff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/develop/external-calls.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: External API call support in Office Scripts
33
description: Support and guidance for making external API calls in an Office Script.
4-
ms.date: 04/27/2023
4+
ms.date: 06/09/2025
55
ms.localizationpriority: medium
66
---
77

@@ -42,9 +42,12 @@ The [fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API) retrieves
4242

4343
Any JSON data retrieved by `fetch` must match an interface defined in the script. The returned value must be assigned to a specific type because [Office Scripts do not support the `any` type](typescript-restrictions.md#no-any-type-in-office-scripts). You should refer to the documentation for your service to see what the names and types of the returned properties are. Then, add the matching interface or interfaces to your script.
4444

45+
> [!NOTE]
46+
> If you use `fetch` to call an external resource with a [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/docs/Web/HTTP/Guides/CORS) policy, make sure that the [`Access-Control-Allow-Origin`](https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Origin) header of that external resource uses the `*` directive. If the `Access-Control-Allow-Origin` header uses a specific `<origin>` directive, then your `fetch` call from Office Scripts may fail. The origin of the Office Scripts runtime may change without notice.
47+
4548
The following script uses `fetch` to retrieve JSON data from the test server in the given URL. Note the `JSONData` interface to store the data as a matching type.
4649

47-
```TypeScript
50+
```typescript
4851
async function main(workbook: ExcelScript.Workbook) {
4952
// Retrieve sample JSON data from a test server.
5053
let fetchResult = await fetch('https://jsonplaceholder.typicode.com/todos/1');

0 commit comments

Comments
 (0)