This repository has been archived on 2023-11-06. You can view files and clone it, but cannot push or open issues or pull requests.
beatsaber-overlay/utils/utils.js
RealFascinated aac2c7027e Updated
Added documentation to methods
Fixed avatars not initially loading
Just generally cleaned up the codebase
2022-04-02 07:01:58 +01:00

24 lines
633 B
JavaScript

import Config from '../config.json';
module.exports = {
BEATSAVER_MAP_API: Config.proxy_url + "/https://api.beatsaver.com/maps/hash/%s",
// todo: cache map data for 12 hrs
/**
* Gets a specified maps data from BeatSaver
*
* @param {string} hash
* @returns The map data
*/
async getMapData(hash) {
const data = await fetch(this.BEATSAVER_MAP_API.replace("%s", hash), {
headers: {
"origin": "Fascinated Overlay"
}
});
if (data.status === 404) {
return undefined;
}
return await data.json();
}
}