Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 7faabda

Browse files
Return empty groups if group api fails
1 parent 07ae64b commit 7faabda

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/common/group-api.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const config = require('config')
22
const _ = require('lodash')
33
const axios = require('axios')
44
const m2mAuth = require('tc-core-library-js').auth.m2m
5+
const logger = require('./logger')
6+
57
const m2m = m2mAuth(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME', 'AUTH0_PROXY_SERVER_URL']))
68

79
/**
@@ -14,13 +16,19 @@ async function getM2Mtoken () {
1416

1517
async function getGroups (universalUID) {
1618
const m2mToken = await getM2Mtoken()
17-
const resp = await axios({
18-
method: 'get',
19-
params: { universalUID },
20-
url: config.GROUP_API_URL,
21-
headers: { Authorization: `Bearer ${m2mToken}` }
22-
})
23-
return resp.data
19+
20+
try {
21+
const resp = await axios({
22+
method: 'get',
23+
params: { universalUID },
24+
url: config.GROUP_API_URL,
25+
headers: { Authorization: `Bearer ${m2mToken}` }
26+
})
27+
return resp.data
28+
} catch (error) {
29+
logger.error(error)
30+
return []
31+
}
2432
}
2533

2634
module.exports = {

0 commit comments

Comments
 (0)