I'm using Office JS framework to get data from a REST API server endpoint using "Custom Function" in Excel(part of Office 365). I'm using the YO generator mentioned in the tutorials(https://learn.microsoft.com/en-us/office/dev/add-ins/quickstarts/excel-custom-functions-quickstart?tabs=excel-windows) I created a custom function which would call REST endpoint to get the data and the result will be placed in the cell. I used same function in multiple cells to get the data. After a threshold number of consecutive calls VALUE! error is returned in the cell. If I recalculate the VALUE! errored cell, it will return the data.
Please help me resolve this issue.
How to reproduce:
Create Custom function project using the tutorial(https://learn.microsoft.com/en-us/office/dev/add-ins/quickstarts/excel-custom-functions-quickstart?tabs=excel-windows) and select language Typescript.
Add following function to the \src\functions\functions.ts file.
/**
* Loads data from REST test service.
* @customfunction TEST_REST_CALL
* @param id ID
* @returns response data.
*/
export async function testRestCall(id: number) {
var response = await fetch(`https://jsonplaceholder.typicode.com/posts/${id}`);
var data = await response.json();
return data.title;
}
- Use the function "TEST_REST_CALL(2)" in no less than 1000 cells.
You will get following VALUE! error for some of the cells.