@crowdin/ota-client
Version:
JavaScript library for Crowdin OTA Content Delivery
18 lines (17 loc) • 570 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchHttpClient = void 0;
class FetchHttpClient {
async get(url) {
const res = await fetch(url);
if (this.isJson(res)) {
return res.json();
}
return res.text();
}
isJson(res) {
var _a, _b;
return ((_b = (_a = res.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Type')) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'application/json';
}
}
exports.FetchHttpClient = FetchHttpClient;