Skip to content

Commit

Permalink
fix(openapi): properly return rejected promise if spec uploads fail
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed Dec 17, 2021
1 parent fa1ccfd commit 0f2372e
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/cmds/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,19 @@ exports.run = async function (opts) {

function createSpec() {
options.method = 'post';
return fetch(`${config.host}/api/v1/api-specification`, options)
.then(res => {
if (res.ok) return success(res);
return error(res);
})
.catch(err => console.log(chalk.red(`\n ${err.message}\n`)));
return fetch(`${config.host}/api/v1/api-specification`, options).then(res => {
if (res.ok) return success(res);
return error(res);
});
}

function updateSpec(specId) {
isUpdate = true;
options.method = 'put';
return fetch(`${config.host}/api/v1/api-specification/${specId}`, options)
.then(res => {
if (res.ok) return success(res);
return error(res);
})
.catch(err => console.log(chalk.red(`\n ${err.message}\n`)));
return fetch(`${config.host}/api/v1/api-specification/${specId}`, options).then(res => {
if (res.ok) return success(res);
return error(res);
});
}

/*
Expand Down

0 comments on commit 0f2372e

Please sign in to comment.