Help with API calls

Hi ,I’m in the process of building a wizard in order to integrate flow meters with taplist. My API calls are failing with fetch in node because of the CORS setup of the server. It looks like the security is setup in such a way that cross origin calls arent allowed. Can anyone help here? @mikey ?

Link to my github with the code so far

Hi Joe!

Ah, since you’re running this in a browser, you’re indeed running into a CORS issue. Can you tell me a little more about how the app will run and work? We can definitely figure out a solution.

Hi Mikey, thanks for the reply.

The main page of the wizard will show a text box for venue and auth_token and set those variables locally. Then, it will pull info of all the taps (I’m also using this as a test to check my fetch is working atm. This is where I’ve got to in the code and I believe it’s correct, but the CORS issue is stopping fetch). After that’s done, I plan to implement code to automatically send a patch request when a variable which holds the liquid level passed through the flow sensors changes, which should then update on taplist. Eventually this will all be put in a Docker container.

I’ve done a fair bit of playing around to try and find a solution, and both an express server and a cors-proxy module in node don’t work when I try to route my fetch requests through them. Any help would be greatly appreciated!

OK understood!

Within a browser, you’re affected by CORS settings. We’ll take a closer look on whether that’s an issue on our side or something that has a workaround (I don’t actually know offhand).

Outside of a browser, e.g. within node in an express route, here’s a snippet that worked for me:

# example.js
const authToken = "<your secret key>";
const venue = "<your venue name>";

async function getTaps() {
  const res = await fetch(
      headers: { Authorization: `Token ${authToken}` },
  const data = await res.json();
  console.log("response:", data);

(async () => {
  await getTaps();

Run with:

node example.js