@@ -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
2222const 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 } ) ;
@@ -405,6 +404,7 @@ const doPost = async (url, bodyparams, headers) => {
405404 try {
406405 const response = await fetch ( url , { method : 'POST' , body : JSON . stringify ( bodyparams ) , headers} ) ;
407406 if ( ! response . ok ) {
407+ //console.log(await response.json());
408408 throw new Error ( 'Request failed with code ' + response . status )
409409 }
410410 return response . json ( ) ;
@@ -417,6 +417,7 @@ const doGet = async (url, params, headers) => {
417417 try {
418418 const response = await fetch ( `${ url } ?` + new URLSearchParams ( params ) , { method : 'GET' , headers} ) ;
419419 if ( ! response . ok ) {
420+ //console.log(await response.json());
420421 throw new Error ( 'Request failed with code ' + response . status )
421422 }
422423 return response . json ( ) ;
0 commit comments