1
0
Fork 0
mirror of https://github.com/fjogeleit/http-request-action.git synced 2024-12-22 20:32:33 +00:00

Update Error Output

Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>
This commit is contained in:
Frank Jogeleit 2022-06-04 10:52:53 +02:00
parent d4c0bee13c
commit e3313c1a5f
3 changed files with 7 additions and 5 deletions

View file

@ -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"}'
```

5
dist/index.js vendored
View file

@ -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)) {

View file

@ -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)) {