@genshin-kit/core
Version:
An API wrapper for fetching player data of Genshin Impact from any servers.
27 lines • 912 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.request = void 0;
const tslib_1 = require("tslib");
const axios_1 = (0, tslib_1.__importDefault)(require("axios"));
/**
* @param path The function will use `${apiEndpoint}/${path}` as the request url, unless `path` starts with `http`
*/
async function request(method, path, data) {
let query, body;
if (method.toLowerCase() === 'get') {
query = data;
}
else {
body = data;
}
return (await (0, axios_1.default)({
method,
url: path.startsWith('http') ? path : `${this._getApiEndpoint()}${path}`,
headers: this._getHttpHeaders({ query, body }),
data: body,
params: query,
...(this.serverType === 'os' ? { withCredentials: true } : {}),
})).data;
}
exports.request = request;
//# sourceMappingURL=request.js.map