@lcap/nasl
Version:
NetEase Application Specific Language
20 lines • 684 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchFile = void 0;
async function fetchFile(url, axios, text) {
if (typeof window !== 'undefined' && typeof window.fetch !== 'undefined') {
const response = await window.fetch(url);
const data = await text ? response.text() : response.json();
return data;
}
const response = await axios.get(url, {
responseType: text ? 'text' : 'json',
responseEncoding: 'utf8',
});
if (response.status !== 200) {
throw new Error('request error!');
}
return response.data;
}
exports.fetchFile = fetchFile;
//# sourceMappingURL=utils.js.map