diff --git a/packages/admin-api/lib/index.js b/packages/admin-api/lib/index.js index d30d5e9cc..364f99c4e 100644 --- a/packages/admin-api/lib/index.js +++ b/packages/admin-api/lib/index.js @@ -21,7 +21,7 @@ module.exports = function GhostAdminAPI(options) { // makeRequest (method) // using es5 destructured parameters // params and headers are optional parameters with an empty object as default value - makeRequest({url, method, data, params = {}, headers = {}}) { + makeRequest({ url, method, data, params = {}, headers = {} }) { // axios: Promise based HTTP client for the browser and node.js // Requests can be made by passing the relevant config to axios i.e axios(config) return axios({ @@ -47,7 +47,7 @@ module.exports = function GhostAdminAPI(options) { const config = Object.assign({}, defaultConfig, options); // new GhostAdminAPI({host: '...'}) is deprecated - + if (config.host) { // eslint-disable-next-line console.warn(`${name}: The 'host' parameter is deprecated, please use 'url' instead`); @@ -295,7 +295,7 @@ module.exports = function GhostAdminAPI(options) { return Promise.reject(new Error('Missing theme name')); } - return makeResourceRequest('themes', {}, {}, 'PUT', {id: `${name}/activate`}); + return makeResourceRequest('themes', {}, {}, 'PUT', { id: `${name}/activate` }); } }; @@ -322,7 +322,7 @@ module.exports = function GhostAdminAPI(options) { if (!Array.isArray(data[resourceType])) { return data[resourceType]; } - + if (data[resourceType].length === 1 && !data.meta) { return data[resourceType][0]; } @@ -346,7 +346,7 @@ module.exports = function GhostAdminAPI(options) { return data; } if (config.formatResponse === true) { - // return data[resourceType] if it is not an array + // return data[resourceType] if it is not an array if (!Array.isArray(data[resourceType])) { return data[resourceType]; } @@ -355,17 +355,17 @@ module.exports = function GhostAdminAPI(options) { return data[resourceType][0]; } //copy the values of all of the enumerable own properties from data.meta as meta data[resourceType]. Returns data[resourceType] - return Object.assign(data[resourceType], {meta: data.meta}); + return Object.assign(data[resourceType], { meta: data.meta }); } else { - return Object.assign(data, {meta: data.meta}); + return Object.assign(data, { meta: data.meta }); } }); } // function endpointFor: returns an endpoint for api request - function endpointFor(resource, {id, slug, email} = {}) { + function endpointFor(resource, { id, slug, email } = {}) { // destructure values from config - const {ghostPath, version} = config; + const { ghostPath, version } = config; // default endpoint let endpoint = `/${ghostPath}/api/${version}/admin/${resource}/`; @@ -383,8 +383,8 @@ module.exports = function GhostAdminAPI(options) { return endpoint; } - function makeApiRequest({endpoint, method, body, queryParams = {}, headers = {}}) { - const {url: apiUrl, key, version, makeRequest} = config; + function makeApiRequest({ endpoint, method, body, queryParams = {}, headers = {} }) { + const { url: apiUrl, key, version, makeRequest } = config; const url = `${apiUrl}${endpoint}`; headers = Object.assign({}, headers, {