mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-11-29 07:10:59 -05:00
add debug statements
This commit is contained in:
parent
b52a6b1b8b
commit
748170326f
1 changed files with 14 additions and 4 deletions
18
src/index.js
18
src/index.js
|
@ -15,6 +15,8 @@ if (!!core.getInput('customHeaders')) {
|
||||||
const headers = { 'Content-Type': core.getInput('contentType') || 'application/json' }
|
const headers = { 'Content-Type': core.getInput('contentType') || 'application/json' }
|
||||||
|
|
||||||
if (!!core.getInput('username') || !!core.getInput('password')) {
|
if (!!core.getInput('username') || !!core.getInput('password')) {
|
||||||
|
core.debug('Add BasicHTTP Auth config')
|
||||||
|
|
||||||
auth = {
|
auth = {
|
||||||
username: core.getInput('username'),
|
username: core.getInput('username'),
|
||||||
password: core.getInput('password')
|
password: core.getInput('password')
|
||||||
|
@ -25,19 +27,27 @@ if (!!core.getInput('bearerToken')) {
|
||||||
headers['Authentication'] = `Bearer ${core.getInput('bearerToken')}`;
|
headers['Authentication'] = `Bearer ${core.getInput('bearerToken')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const instance = axios.create({
|
const instanceConfig = {
|
||||||
baseURL: core.getInput('url', { required: true }),
|
baseURL: core.getInput('url', { required: true }),
|
||||||
timeout: parseInt(core.getInput('timeout') || 5000, 10),
|
timeout: parseInt(core.getInput('timeout') || 5000, 10),
|
||||||
headers: { ...headers, ...customHeaders }
|
headers: { ...headers, ...customHeaders }
|
||||||
});
|
}
|
||||||
|
|
||||||
|
core.debug(JSON.stringify(instanceConfig))
|
||||||
|
|
||||||
|
const instance = axios.create(instanceConfig);
|
||||||
|
|
||||||
(async() => {
|
(async() => {
|
||||||
try {
|
try {
|
||||||
const response = await instance.request({
|
const requestData = {
|
||||||
auth,
|
auth,
|
||||||
method: core.getInput('method') || 'POST',
|
method: core.getInput('method') || 'POST',
|
||||||
data: JSON.parse(core.getInput('data') || '{}')
|
data: JSON.parse(core.getInput('data') || '{}')
|
||||||
})
|
}
|
||||||
|
|
||||||
|
core.debug(JSON.stringify(requestData))
|
||||||
|
|
||||||
|
const response = await instance.request(requestData)
|
||||||
|
|
||||||
core.setOutput('response', JSON.stringify(response.data))
|
core.setOutput('response', JSON.stringify(response.data))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in a new issue