mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-12-23 04:37:28 +00:00
Adding ability to return headers without setting debug mode (#51)
* Update httpClient.js * Update README.md * Update action.yml Co-authored-by: Nick Hills <nick.hills@valtech.com>
This commit is contained in:
parent
cce3f3d779
commit
4cbc7a46b2
4 changed files with 8 additions and 0 deletions
|
@ -48,6 +48,7 @@ jobs:
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
`response` | Response as JSON String
|
`response` | Response as JSON String
|
||||||
|
`headers` | Headers
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ steps:
|
||||||
- name: Show Response
|
- name: Show Response
|
||||||
run: |
|
run: |
|
||||||
echo ${{ steps.myRequest.outputs.response }}
|
echo ${{ steps.myRequest.outputs.response }}
|
||||||
|
echo ${{ steps.myRequest.outputs.headers }}
|
||||||
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
|
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ inputs:
|
||||||
outputs:
|
outputs:
|
||||||
response:
|
response:
|
||||||
description: 'HTTP Response Content'
|
description: 'HTTP Response Content'
|
||||||
|
headers:
|
||||||
|
description: 'HTTP Response Headers'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
|
@ -1968,6 +1968,8 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
|
||||||
const response = await instance.request(requestData)
|
const response = await instance.request(requestData)
|
||||||
|
|
||||||
actions.setOutput('response', JSON.stringify(response.data))
|
actions.setOutput('response', JSON.stringify(response.data))
|
||||||
|
|
||||||
|
actions.setOutput('headers', response.headers)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
||||||
const { name, message, code, response } = error
|
const { name, message, code, response } = error
|
||||||
|
|
|
@ -68,6 +68,8 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
|
||||||
const response = await instance.request(requestData)
|
const response = await instance.request(requestData)
|
||||||
|
|
||||||
actions.setOutput('response', JSON.stringify(response.data))
|
actions.setOutput('response', JSON.stringify(response.data))
|
||||||
|
|
||||||
|
actions.setOutput('headers', response.headers)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
||||||
const { name, message, code, response } = error
|
const { name, message, code, response } = error
|
||||||
|
|
Loading…
Reference in a new issue