Skip to content

Commit

Permalink
adding try & catch to API request
Browse files Browse the repository at this point in the history
  • Loading branch information
koebel committed Aug 14, 2024
1 parent 7ff32d4 commit 4ed9e13
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tests/e2e/api/APIHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import axios from 'axios'
import join from 'join-path'

export const sendRequest = function ({ method, path, header = null, data = null }): Promise<any> {
const headers = {
...header,
Authorization: `Basic ${Buffer.from(`${config.adminUser}:${config.adminPassword}`).toString(
'base64'
)}`
try {
const headers = {
...header,
Authorization: `Basic ${Buffer.from(`${config.adminUser}:${config.adminPassword}`).toString(
'base64'
)}`
}
return axios({
method,
url: join(config.baseUrlOcis, path),
headers,
data
})
} catch (error) {
throw new Error(error.message)
}

return axios({
method,
url: join(config.baseUrlOcis, path),
headers,
data
})
}

0 comments on commit 4ed9e13

Please sign in to comment.