1

I'm getting a Line 15: Failed to fetch error without further details.

This is my script in Excel Web.

async function main(workbook: ExcelScript.Workbook) {
    let sheet = workbook.getActiveWorksheet();
    const company:string  = String(sheet.getRange("C4").getValue());
  const id: string = String(sheet.getRange("C5").getValue());

  sheet.getRange('D4').setValue(await getairequest(company, id));
  sheet.getRange('D5').setValue(Date());

}

async function getairequest(company: string, id: string): Promise <string>{
  const link = encodeURI('{CUSTOM LINK}/' + company + '/' + id);

  console.log(link);
  const response = await fetch(link);
  

  const { data }: { data: JSONData } = await response.json();


  //const json: JSONData = await response.json();
  console.log(JSON.stringify(data));

  return data.text;

}


interface JSONData {
  text: string;
  index: number;
  logprobs: string;
  finish_reason: string;
}

The response of the link is the following:

{"text":"individual text result","index":0,"logprobs":null,"finish_reason":"stop"},

Script will be executed directly in Excel Online (Not via Power Automate), I'm able to modify the response of the Custom Link, due to the fact that this is an internal tool.

Fetch the JSON and put the answer into a cell in Excel.

Kay B
  • 11
  • 2

0 Answers0