Skip to content

Commit

Permalink
fix: always work with uppercased verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Jun 4, 2020
1 parent 7ebc3d7 commit ac2a45e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib/request/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ const makeSnykRequest = async (request: snykRequest) => {
'Authorization': 'token '+userConfig.token,
'User-Agent': 'tech-services/snyk-prevent/1.0'
}

const apiClient = axios.create({
baseURL: userConfig.endpoint,
responseType: 'json',
headers: {...requestHeaders, ...request.headers }
});

try {
let res;
switch(request.verb){
switch(request.verb.toUpperCase()){
case "GET":
res = await apiClient.get(request.url)
break;
Expand All @@ -43,7 +43,7 @@ const makeSnykRequest = async (request: snykRequest) => {
throw new Error.GenericError('Unexpected http command')
}
return res?.data

} catch (err) {
switch(err.response.status){
case 401:
Expand All @@ -56,8 +56,8 @@ const makeSnykRequest = async (request: snykRequest) => {
throw new Error.GenericError(err)
}
}


}

const getConfig = () => {
Expand All @@ -69,5 +69,5 @@ const getConfig = () => {
export {
makeSnykRequest,
getConfig,
snykRequest
}
snykRequest
}

0 comments on commit ac2a45e

Please sign in to comment.