I am trying to call an external API (https://api.fortnox.se/3/customers/2) from an Excel on web.
The Web API I am calling returns a jason data structure such as the "Response" under "Retrieve a customer" session here: https://developer.fortnox.se/documentation/resources/customers/
Response data structure:
{
    "Customer": {
        "@url": "https://api.fortnox.se/3/customers/102",
        "Active": true,
        "Address1": "Halltorpsgatan",
        "Address2": null,
        "City": "KLIPPAN",
        "Comments": null,
        "CostCenter": null,
        "Country": "Sverige",
        "CountryCode": "SE",
        "Currency": "SEK",
        "CustomerNumber": "102",
        "DefaultDeliveryTypes": {
            "Invoice": "PRINT",
            "Offer": "PRINT",
            "Order": "PRINT"
        },
        "DefaultTemplates": {
            "CashInvoice": "DEFAULTTEMPLATE",
            "Invoice": "DEFAULTTEMPLATE",
            "Offer": "DEFAULTTEMPLATE",
            "Order": "DEFAULTTEMPLATE"
        },
        "DeliveryAddress1": null,
        "DeliveryAddress2": null,
        "DeliveryCity": null,
        "DeliveryCountry": null,
        "DeliveryCountryCode": null,
        "DeliveryFax": null,
        "DeliveryName": null,
        "DeliveryPhone1": null,
        "DeliveryPhone2": null,
        "DeliveryZipCode": null,
        "Email": "a.s@example.com",
        "EmailInvoice": "a.s@example.com",
        "EmailInvoiceBCC": "",
        "EmailInvoiceCC": "",
        "EmailOffer": "a.s@example.com",
        "EmailOfferBCC": "",
        "EmailOfferCC": "",
        "EmailOrder": "a.s@example.com",
        "EmailOrderBCC": "",
        "EmailOrderCC": "",
        "Fax": null,
        "GLN": null,
        "GLNDelivery": null,
        "InvoiceAdministrationFee": null,
        "InvoiceDiscount": null,
        "InvoiceFreight": null,
        "InvoiceRemark": "",
        "Name": "Anders Svensson",
        "OrganisationNumber": "",
        "OurReference": "",
        "Phone1": "0435-9249236",
        "Phone2": null,
        "PriceList": "A",
        "Project": "",
        "SalesAccount": null,
        "ShowPriceVATIncluded": false,
        "TermsOfDelivery": "",
        "TermsOfPayment": "",
        "Type": "PRIVATE",
        "VATNumber": "",
        "VATType": "SEVAT",
        "VisitingAddress": null,
        "VisitingCity": null,
        "VisitingCountry": null,
        "VisitingCountryCode": null,
        "VisitingZipCode": null,
        "WWW": "",
        "WayOfDelivery": "",
        "YourReference": "",
        "ZipCode": "264 32"
    }
}
Inspired by the Stackoverflow post here: Fetch error on Office Script (Excel on web) I wrote the following code:
interface aCustomer {
  Customer: CustomerClass;
}
interface CustomerClass {
  Address1: string;
  Country: string;
}
async function main(workbook: ExcelScript.Workbook): Promise<void> {
  let response = await fetch("https://api.fortnox.se/3/customers/2", {
    method: "GET",
    mode: "no-cors",
    headers: {
      "Access-Token": "XXXX",
      "Client-Secret": "XXXX",
      "Content-Type": "application/json",
      "Accept": "application/json"
    }
  });
  let customer2: aCustomer = await response.json();
  console.log(customer2);
}
But when I ran it kept throwing the error: "Line 21: Unexpected end of input"
Line 21: let customer2: Customer = await response.json()
I guess I have defined a wrong interface, or otherwise any idea what the problem might be? Thanks!