UNPKG

@lighthouse-web3/sdk

Version:

NPM package and CLI tool to interact with lighthouse protocol

26 lines (25 loc) 844 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lighthouse_config_1 = require("../../lighthouse.config"); exports.default = async (apiKey) => { try { // Get users data usage const response = await fetch(lighthouse_config_1.lighthouseConfig.lighthouseAPI + `/api/user/user_data_usage`, { headers: { Authorization: `Bearer ${apiKey}`, }, }); if (!response.ok) { throw new Error(`Request failed with status code ${response.status}`); } const userDataUsage = (await response.json()); /* return: { data: { dataLimit: 1073741824, dataUsed: 1062512300 } } */ return { data: userDataUsage }; } catch (error) { throw new Error(error.message); } };