After some learning curve to get the Lichess API to work, I have distilled a small test program from what I learnt.
It will use my API token and retrieve my username from the Lichess accounts API.
There's no error checking etc as I wanted as small a demo program as reasonably possible.
const baseURL = "lichess.org/"
const APITOKEN = "YourAPItokenHere"
const axios = require('axios')
const headers = {Authorization: `Bearer ${APITOKEN}`}
const lichess = {baseURL, headers};
(async () => {console.log((await axios.get('/api/account', lichess)).data.username)})();
It will use my API token and retrieve my username from the Lichess accounts API.
There's no error checking etc as I wanted as small a demo program as reasonably possible.
const baseURL = "lichess.org/"
const APITOKEN = "YourAPItokenHere"
const axios = require('axios')
const headers = {Authorization: `Bearer ${APITOKEN}`}
const lichess = {baseURL, headers};
(async () => {console.log((await axios.get('/api/account', lichess)).data.username)})();