mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-12-29 05:14:52 -05:00
Update Error Output
Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>
This commit is contained in:
parent
d4c0bee13c
commit
e3313c1a5f
3 changed files with 7 additions and 5 deletions
|
@ -15,7 +15,7 @@ jobs:
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
username: ${{ secrets.AWX_USER }}
|
username: ${{ secrets.AWX_USER }}
|
||||||
password: ${{ secrets.AWX_PASSWORD }}
|
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"}'
|
data: '{"key_1": "value_1", "key_2": "value_2"}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
5
dist/index.js
vendored
5
dist/index.js
vendored
|
@ -1969,8 +1969,9 @@ const request = async({ method, instanceConfig, data, files, file, auth, actions
|
||||||
|
|
||||||
actions.setOutput('response', JSON.stringify(response.data))
|
actions.setOutput('response', JSON.stringify(response.data))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.toJSON) {
|
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
||||||
actions.setOutput('requestError', JSON.stringify(error.toJSON()));
|
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)) {
|
if (error.response && ignoredCodes.includes(error.response.status)) {
|
||||||
|
|
|
@ -71,8 +71,9 @@ const request = async({ method, instanceConfig, data, files, file, auth, actions
|
||||||
|
|
||||||
actions.setOutput('response', JSON.stringify(response.data))
|
actions.setOutput('response', JSON.stringify(response.data))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.toJSON) {
|
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
||||||
actions.setOutput('requestError', JSON.stringify(error.toJSON()));
|
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)) {
|
if (error.response && ignoredCodes.includes(error.response.status)) {
|
||||||
|
|
Loading…
Reference in a new issue