diff --git a/server/controllers/api.js b/server/controllers/api.js index 26976ad1701..ea5f255c7bc 100644 --- a/server/controllers/api.js +++ b/server/controllers/api.js @@ -139,13 +139,9 @@ const handleHarborProxy = async ctx => { let isErrorRes = false if (requestUrl === 'search') { - const { repository, project, chart } = res + const { repository, project } = res // Check whether the response is the requirements - isErrorRes = !( - Array.isArray(repository) && - Array.isArray(project) && - Array.isArray(chart) - ) + isErrorRes = !(Array.isArray(repository) && Array.isArray(project)) } else { isErrorRes = !Array.isArray(res) } diff --git a/server/libs/request.js b/server/libs/request.js index ef04e8efbbe..da9a7cc4aaf 100644 --- a/server/libs/request.js +++ b/server/libs/request.js @@ -111,7 +111,7 @@ const send_harbor_request = ({ path, params }) => { const contentType = response.headers.get('content-type') if (contentType && contentType.includes('json')) { - return response.json().then(res => { + response.json().then(res => { if (res.errors) { const errorMsg = res.errors[0] ? res.errors[0].message @@ -123,7 +123,6 @@ const send_harbor_request = ({ path, params }) => { resolve({ repository: [], project: [], chart: [] }) } } - if ( response.ok && response.status >= 200 && @@ -138,13 +137,13 @@ const send_harbor_request = ({ path, params }) => { statusText: response.statusText, }) }) + } else { + reject({ + code: 400, + statusText: response.statusText, + message: 'bad request', + }) } - - reject({ - code: 400, - statusText: response.statusText, - message: 'bad request', - }) }) .catch(err => { reject(err)