I am trying to access a function called in return of another function, but when I access it normally I get the error:
TypeError: adminSdk.InsertGameAuthRefreshTokens is not a function
at insertGameAuthRefreshTokens (D:\Projects\CHRIS\vsm-nft-fe\.next\server\pages\api\gameAuthCallback.js:1496:20)
at handler (D:\Projects\CHRIS\vsm-nft-fe\.next\server\pages\api\gameAuthCallback.js:1434:26)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Object.apiResolver (D:\Projects\CHRIS\vsm-nft-fe\node_modules\next\dist\server\api-utils.js:114:13)
at async DevServer.handleApiRequest (D:\Projects\CHRIS\vsm-nft-fe\node_modules\next\dist\server\next-server.js:763:9)
at async Object.fn (D:\Projects\CHRIS\vsm-nft-fe\node_modules\next\dist\server\next-server.js:654:37)
at async Router.execute (D:\Projects\CHRIS\vsm-nft-fe\node_modules\next\dist\server\router.js:206:32)
at async DevServer.run (D:\Projects\CHRIS\vsm-nft-fe\node_modules\next\dist\server\next-server.js:831:29)
at async DevServer.handleRequest (D:\Projects\CHRIS\vsm-nft-fe\node_modules\next\dist\server\next-server.js:295:20)
Here's the function that I want to acess (funcName)
const adminSdk = getAdminSdk({
endpoint,
adminSecret,
})
return {
async funcName(data) {
const { graphql_mutation_name: response } = adminSdk.generatedFuncName({ data })
return {
userId: response.user_id,
}
},
}
}
and here's how I am calling the function
const sdk = HasuraAdapter(args)
const { funcName} = sdk
const response = await funcName(data)
console.log(response)
Anyone who can help me on how to access that function in return{} statement?
CodePudding user response:
Either the function isn't being recognized in the return, or sdk isn't being recognized having that function member. Console log to double check "sdk" and "HasuraAdapter(args)" actually have a function attached. Generally, to call a function in the return of a function, you would do something like this: