Skip to content

Commit 19158d0

Browse files
committed
remove need of adminheader for score
simplified generation of header with tokens
1 parent 8015b7d commit 19158d0

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

sample-server/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const defaultHeader = {
1818
'api-version': '1.0'
1919
};
2020

21-
// Admin Token + ApiKey are needed for approving and fetching scores
21+
// Admin Token + ApiKey are needed for approving
2222
const adminHeader = {
2323
'Content-Type': "application/json",
2424
'x-api-key': process.env.API_KEY,
@@ -86,12 +86,9 @@ app.get('/onboarding-url', async (req, res) => {
8686
}
8787
const {token, interviewId} = startData;
8888

89-
const onboardingHeader = {
90-
'Content-Type': "application/json",
91-
'X-Incode-Hardware-Id': startData.token,
92-
'x-api-key': process.env.API_KEY,
93-
'api-version': '1.0'
94-
};
89+
const onboardingHeader = {...defaultHeader};
90+
onboardingHeader['X-Incode-Hardware-Id'] = startData.token;
91+
9592
const onboardingUrl = `${process.env.API_URL}/0/omni/onboarding-url`;
9693

9794
let onboardingUrlData= null;
@@ -139,17 +136,19 @@ app.get('/fetch-score', async (req, res) => {
139136

140137
//Get the token of the session from the headers
141138
let token = req.headers["x-token"];
142-
if(!token) {
139+
if (!token) {
143140
res.status(400).send({success:false, error:'Missing required header X-Token'});
144141
return;
145142
}
146-
adminHeader['X-Incode-Hardware-Id'] = token;
143+
144+
scoreHeader = {...defaultHeader};
145+
scoreHeader['X-Incode-Hardware-Id'] = token;
147146

148147
//Let's find out the score
149148
const scoreUrl = `${process.env.API_URL}/omni/get/score`;
150149
let onboardingScore = null
151150
try {
152-
onboardingScore = await doGet(scoreUrl, {id:interviewId}, adminHeader);
151+
onboardingScore = await doGet(scoreUrl, {id:interviewId}, scoreHeader);
153152
} catch(e) {
154153
console.log(e.message);
155154
res.status(500).send({success:false, error: e.message});

0 commit comments

Comments
 (0)