mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-11-22 03:41:00 -05:00
commit
fb4418ffc0
3 changed files with 16 additions and 6 deletions
12
README.md
12
README.md
|
@ -15,8 +15,14 @@ jobs:
|
|||
method: 'POST'
|
||||
username: ${{ secrets.AWX_USER }}
|
||||
password: ${{ secrets.AWX_PASSWORD }}
|
||||
customHeaders: '{"Content-Type": "application/json"}'
|
||||
data: '{"key_1": "value_1", "key_2": "value_2"}'
|
||||
```
|
||||
|
||||
### Versioning
|
||||
|
||||
`master` branch is deprecated. Please use `main` or `v1` to get the latest version of this action. It is recommended to use a fixed version.
|
||||
|
||||
### Request Configuration
|
||||
|
||||
|Argument| Description | Default |
|
||||
|
@ -42,7 +48,7 @@ jobs:
|
|||
|---|---|
|
||||
`response` | Response as JSON String
|
||||
|
||||
To display HTTP response data in the GitHub Actions log give the request an `id` and access its `outputs`
|
||||
To display HTTP response data in the GitHub Actions log give the request an `id` and access its `outputs`. You can also access specific field from the response data using [fromJson()](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) expression.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
|
@ -52,7 +58,9 @@ steps:
|
|||
with:
|
||||
url: "http://yoursite.com/api"
|
||||
- name: Show Response
|
||||
run: echo ${{ steps.myRequest.outputs.response }}
|
||||
run: |
|
||||
echo ${{ steps.myRequest.outputs.response }}
|
||||
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
|
||||
```
|
||||
|
||||
### Additional Information
|
||||
|
|
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))
|
||||
} 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)) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue