How to use the Coda API using JS?

Hi guys!

Is anyone familiar with using the Coda API using Javascript?

I am trying to make a simple call, using a test token, but it keeps returning 401 “Unauthorized” errors.

$(document).ready(function() {
    $.ajax({
      url: "https://coda.io/apis/v1/docs",
      type: "GET",
      headers: {"Authorization": 'TOKEN'},
      success: function(result) {
        console.log(result);
      },
      error: function(error) {
        console.log(error);
      }
    });
  });

I am pretty sure it’s a fairly basic formatting issue, however, the docs don’t demonstrate JS calls.

Is anyone familiar with doing this in JS?

1 Like

Try changing the headers to:

headers: {"Authorization": 'Bearer TOKEN'},

The reference on the Authorization header is here: https://coda.io/developers/apis/v1#section/Authentication/Bearer

1 Like

That worked! Thanks!

1 Like