antora-confluence
Version:
A tool to convert and publish Antora documentation to Confluence
30 lines (29 loc) • 910 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendRequest = void 0;
const Logger_1 = require("../Logger");
const LOGGER = (0, Logger_1.getLogger)();
const sendRequest = async (call) => {
try {
const response = await call;
if (response.status === 404) {
return { results: [] };
}
if (response.status === 403) {
LOGGER.error(`Publish failed due to insufficient permissions or wrong credentials`);
process.exit(1);
}
if (response.status === 204) {
return;
}
if (response.status > 299) {
LOGGER.warn(`Publish failed with response ${response.status}`);
LOGGER.warn(await response.text());
}
return await response.json();
}
catch (error) {
LOGGER.error(error);
}
};
exports.sendRequest = sendRequest;