1
0
Fork 0
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:
Nick Hills 2022-08-17 08:56:02 +01:00 committed by GitHub
parent cce3f3d779
commit 4cbc7a46b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 0 deletions

View file

@ -48,6 +48,7 @@ jobs:
| Variable | Description |
|---|---|
`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.
@ -61,6 +62,7 @@ steps:
- name: Show Response
run: |
echo ${{ steps.myRequest.outputs.response }}
echo ${{ steps.myRequest.outputs.headers }}
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
```

View file

@ -53,6 +53,8 @@ inputs:
outputs:
response:
description: 'HTTP Response Content'
headers:
description: 'HTTP Response Headers'
runs:
using: 'node16'
main: 'dist/index.js'

2
dist/index.js vendored
View file

@ -1968,6 +1968,8 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
const response = await instance.request(requestData)
actions.setOutput('response', JSON.stringify(response.data))
actions.setOutput('headers', response.headers)
} catch (error) {
if ((typeof error === 'object') && (error.isAxiosError === true)) {
const { name, message, code, response } = error

View file

@ -68,6 +68,8 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
const response = await instance.request(requestData)
actions.setOutput('response', JSON.stringify(response.data))
actions.setOutput('headers', response.headers)
} catch (error) {
if ((typeof error === 'object') && (error.isAxiosError === true)) {
const { name, message, code, response } = error