Kirby KQL without buffer

Im building a little static HTML site built using Vite and trying to get data from a headless Kirby instance, but hitting a blocker

The KQL docs say to do this to authenticate with the API:

const headers = {
  Authorization: "Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
  "Content-Type": "application/json",
  Accept: "application/json",
};

Trouble is buffer is part of node so im getting build errors there since this isnt a node project as such, Its just plain HTML and Vanilla JS compiled using Vite. How do i re-write that so that it does not use buffer, or should i use something like Axios instead? Id rather not do that because it means adding another dependency to the project and extra JS file size.

Ok Nevermind, this works:

const headers = {
  Authorization:
  "Basic " + `${username}:${password}`,
  "Content-Type": "application/json",
  Accept: "application/json",
};

What id like to understand what is the advantage of using Buffer, and base64?