Getting Table Records from the API in JavaScript

Hey All,

Wanted to share something that I struggled with some. I wanted to make a different table viewer, but this meant I needed to be able to hit the tables api to get all of its records. Here is a function that does just that. Two things you need to change:

  1. Create a bot in your instance, and copy its basic auth code to the authorizationBasic variable.
  2. Update the URL you want to pull data from inside the request object.
async function callAPI() {
  console.log("in fetch machine data")
  const authorizationBasic =
    "Basic YXB...NmlXag==";

  let myHeaders = new Headers();
  myHeaders.append("Accept", "application/json");
  myHeaders.append("Authorization", authorizationBasic);
    "application/x-www-form-urlencoded; charset=UTF-8"

  const myInit = {
    method: "GET",
    headers: myHeaders,
    mode: "cors",
    cache: "default"

  let myRequest = new Request(

  const response = await fetch(myRequest, myInit);
  const machineData = await response.json();
  return machineData;

Some resources if you have never worked with the api:

Let me know if you run into any issues as we can work through them as a team-