Here’s a rough example of how to include the API Token in the request header:
function preload() {
let url = 'https://littlesis.org/api/entities/1';
httpDo(
url,
{
method: 'GET',
// Other Request options, like special headers for apis
headers: { 'littlesis-api-token': 'YOUR_TOKEN_HERE'},
mode: 'no-cors',// no-cors, *cors, same-origin
credentials: 'include',// include, *same-origin, omit
redirect: 'follow', // manual, *follow, error
referrer: 'client', // no-referrer, *client
},
function(res) {
console.log(res);
},
function(err) {
console.log(err);
}
);
}
function setup() {
createCanvas(300, 300);
}
function draw() {
}
I am getting CORS related errors and unfortunately unable to provide a quick solution, but I’m sure the more web experienced will provide advice there.
As a hacky backup-plan I can suggest using a basic server side script to cache the request locally so p5.js can access it. (e.g. a node script that receives the same request you would to little-sister, does the request and funnels the message back, but from localhost/same domain the p5 sketch is served from)