Hi, please help, this code loads a variable with a token only 1 time, and with further updating of values in the database, the old value remains in the code. I want to make sure that every time the API is requested, the script takes a new value.
const db = new sqlite3.Database('database.db');
interface Row {
token: string;
}
const getCookieFromDatabase = () => {
return new Promise<string>((resolve, reject) => {
db.get('SELECT token FROM cookies LIMIT 1', (err, row: Row) => {
if (err) {
reject(err);
} else {
console.log(row)
resolve(row?.token || '');
}
});
});
};
const newSunoApi = async () => {
const cookie = await getCookieFromDatabase();
const sunoApi = new SunoApi(cookie);
return await sunoApi.init();
};
export const sunoApi = newSunoApi();