diff --git a/README.md b/README.md index efccf00..0495974 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ jobs: method: 'POST' username: ${{ secrets.AWX_USER }} password: ${{ secrets.AWX_PASSWORD }} - customHeaders: '{"Authorization": "Bearer ${{ secrets.TOKEN }}", "Content-Type": "application/json"}' + customHeaders: '{"Content-Type": "application/json"}' data: '{"key_1": "value_1", "key_2": "value_2"}' ``` diff --git a/dist/index.js b/dist/index.js index 974d4e3..85dda49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1969,8 +1969,9 @@ const request = async({ method, instanceConfig, data, files, file, auth, actions actions.setOutput('response', JSON.stringify(response.data)) } catch (error) { - if (error.toJSON) { - actions.setOutput('requestError', JSON.stringify(error.toJSON())); + if ((typeof error === 'object') && (error.isAxiosError === true)) { + const { name, message, code, response } = error + actions.setOutput('requestError', JSON.stringify({ name, message, code, status: response && response.status ? response.status : null })); } if (error.response && ignoredCodes.includes(error.response.status)) { diff --git a/src/httpClient.js b/src/httpClient.js index c167ab6..6cef368 100644 --- a/src/httpClient.js +++ b/src/httpClient.js @@ -71,8 +71,9 @@ const request = async({ method, instanceConfig, data, files, file, auth, actions actions.setOutput('response', JSON.stringify(response.data)) } catch (error) { - if (error.toJSON) { - actions.setOutput('requestError', JSON.stringify(error.toJSON())); + if ((typeof error === 'object') && (error.isAxiosError === true)) { + const { name, message, code, response } = error + actions.setOutput('requestError', JSON.stringify({ name, message, code, status: response && response.status ? response.status : null })); } if (error.response && ignoredCodes.includes(error.response.status)) {