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

Commit b917f0a

Browse files
author
vikasrohit
authored
Readded getUbahnResource helper
It was called by getUser method as well
1 parent 57d98ab commit b917f0a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/common/helper.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ async function getV5SkillResource (path, params) {
6060
return result
6161
}
6262

63+
/**
64+
* Get the ubahn record
65+
* @param {String} path the resource path
66+
* @param {String} params the query params
67+
* @returns {Object} the u-bahn user
68+
*/
69+
async function getUbahnResource (path, params) {
70+
const token = await getM2MUbahnToken()
71+
const res = await axios.get(`${config.UBAHN_API_URL}/${path}`, {
72+
params,
73+
headers: { Authorization: `Bearer ${token}` }
74+
})
75+
const result = _.head(_.get(res, 'data'))
76+
if (!result) {
77+
throw Error(`Cannot find u-bahn resource ${path} with params ${JSON.stringify(params)}`)
78+
}
79+
return result
80+
}
81+
6382
/**
6483
* Create user skill
6584
* @param {String} userId the user id

0 commit comments

Comments
 (0)