UNPKG

oa-jira

Version:

Octet Agile's JIRA connectivity project.

22 lines (19 loc) 711 B
const axios = require('axios'); const commons = require('../../commons'); const handleError = (url, error) => { if (!error.response) return Promise.reject(error); return error.response.status === 404 ? Promise.resolve() : commons.errors.fail.reject(`Get [${url}] (Status ${error.response.status})`); }; /** * Used to operate a get, trhough axios libreay, for a specific url and configuration. * @param {string} url The url. * @param {object} config The axios config. */ exports.get = (url, config) => { return axios .get(url, config) .then(response => Promise.resolve(response?.data ? response.data : undefined)) .catch(error => handleError(url, error)); };