0

I found an API I'd like to use for my webpage, this is the code snippet they provided. I have tested it with the API token pasted into const API_TOKEN, and it still catches with the error message [object Error] { ... }

const API_TOKEN = ""; // Insert your API token from your dashboard

fetch("https://api.neuro-ai.co.uk/SyncPredict?include_result=true", {
  method: "POST",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
    Authorization: `Bearer ${API_TOKEN}`,
  },
  body: JSON.stringify({
    modelId: "60ca2a1e54f6ecb69867c72c",
    data: ["When I visit Bath I will"],
    input_kwargs: {
      max_length: 15
    },
  }),
}).catch((error) => {
  console.error('Error:', error);
});

I was wondering if there were any obvious syntactical errors in the code, or if I'm somehow calling the API incorrectly.

Phil
  • 157,677
  • 23
  • 242
  • 245

0 Answers0