Node JS self._callback.apply is not a function error
import axios from 'axios';
import * as jwt from 'jsonwebtoken';
import Action from 'routing-controllers';
import Connection from 'typeorm';
import env from '../env';
export function authorizationChecker( connection: Connection): (action: Action, roles: any) => Promise<boolean> | boolean
let validationKey: any = axios.get(env.auth.jwksUri).then(response =>
validationKey = response.data.keys[0].value;
).catch();
return async function innerAuthorizationChecker(
action: Action,
roles: string
): Promise<boolean>
// here you can use request/response objects from action
// also if decorator defines roles it needs to access the actio
// you can use them to provide granular access check
// checker must return either boolean (true or false)
// either promise that resolves a boolean value
try
const token = (action.request.headers.token catch (e)
return false;
;
This is my error:
error: [app] Application is crashed: TypeError: self._callback.apply is not a function
(node:512) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '0' of undefined
(node:512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js
process with a non-zero exit code.
I'm trying to get the validation key set from a specific URL from a service, but somehow (without calling the function) it says that the response data is undefined. On top of that, I'm having this error: self._callback.apply is not a function.
Has someone dealt with such a callback error before? I couldn't find anything on stackoverflow relating to my problem.
javascript node.js typescript callback
add a comment |
import axios from 'axios';
import * as jwt from 'jsonwebtoken';
import Action from 'routing-controllers';
import Connection from 'typeorm';
import env from '../env';
export function authorizationChecker( connection: Connection): (action: Action, roles: any) => Promise<boolean> | boolean
let validationKey: any = axios.get(env.auth.jwksUri).then(response =>
validationKey = response.data.keys[0].value;
).catch();
return async function innerAuthorizationChecker(
action: Action,
roles: string
): Promise<boolean>
// here you can use request/response objects from action
// also if decorator defines roles it needs to access the actio
// you can use them to provide granular access check
// checker must return either boolean (true or false)
// either promise that resolves a boolean value
try
const token = (action.request.headers.token catch (e)
return false;
;
This is my error:
error: [app] Application is crashed: TypeError: self._callback.apply is not a function
(node:512) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '0' of undefined
(node:512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js
process with a non-zero exit code.
I'm trying to get the validation key set from a specific URL from a service, but somehow (without calling the function) it says that the response data is undefined. On top of that, I'm having this error: self._callback.apply is not a function.
Has someone dealt with such a callback error before? I couldn't find anything on stackoverflow relating to my problem.
javascript node.js typescript callback
2
response.data.keys[0]
has a "property 0", so the error implies thatkeys
there is not actually defined. Also a lot of other problems here.return async function()
does not do what you seem to think it does, and it's not really clear here what you are expecting. Needs more context as well as some basic debugging.
– Neil Lunn
Nov 12 '18 at 8:52
I know that response.data.keys[0] is not defined. but how can it be defined if the value is being called from an api?
– Slyckies
Nov 12 '18 at 12:30
add a comment |
import axios from 'axios';
import * as jwt from 'jsonwebtoken';
import Action from 'routing-controllers';
import Connection from 'typeorm';
import env from '../env';
export function authorizationChecker( connection: Connection): (action: Action, roles: any) => Promise<boolean> | boolean
let validationKey: any = axios.get(env.auth.jwksUri).then(response =>
validationKey = response.data.keys[0].value;
).catch();
return async function innerAuthorizationChecker(
action: Action,
roles: string
): Promise<boolean>
// here you can use request/response objects from action
// also if decorator defines roles it needs to access the actio
// you can use them to provide granular access check
// checker must return either boolean (true or false)
// either promise that resolves a boolean value
try
const token = (action.request.headers.token catch (e)
return false;
;
This is my error:
error: [app] Application is crashed: TypeError: self._callback.apply is not a function
(node:512) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '0' of undefined
(node:512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js
process with a non-zero exit code.
I'm trying to get the validation key set from a specific URL from a service, but somehow (without calling the function) it says that the response data is undefined. On top of that, I'm having this error: self._callback.apply is not a function.
Has someone dealt with such a callback error before? I couldn't find anything on stackoverflow relating to my problem.
javascript node.js typescript callback
import axios from 'axios';
import * as jwt from 'jsonwebtoken';
import Action from 'routing-controllers';
import Connection from 'typeorm';
import env from '../env';
export function authorizationChecker( connection: Connection): (action: Action, roles: any) => Promise<boolean> | boolean
let validationKey: any = axios.get(env.auth.jwksUri).then(response =>
validationKey = response.data.keys[0].value;
).catch();
return async function innerAuthorizationChecker(
action: Action,
roles: string
): Promise<boolean>
// here you can use request/response objects from action
// also if decorator defines roles it needs to access the actio
// you can use them to provide granular access check
// checker must return either boolean (true or false)
// either promise that resolves a boolean value
try
const token = (action.request.headers.token catch (e)
return false;
;
This is my error:
error: [app] Application is crashed: TypeError: self._callback.apply is not a function
(node:512) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property '0' of undefined
(node:512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js
process with a non-zero exit code.
I'm trying to get the validation key set from a specific URL from a service, but somehow (without calling the function) it says that the response data is undefined. On top of that, I'm having this error: self._callback.apply is not a function.
Has someone dealt with such a callback error before? I couldn't find anything on stackoverflow relating to my problem.
javascript node.js typescript callback
javascript node.js typescript callback
edited Nov 12 '18 at 9:33
Hannah May
1226
1226
asked Nov 12 '18 at 8:45
SlyckiesSlyckies
62
62
2
response.data.keys[0]
has a "property 0", so the error implies thatkeys
there is not actually defined. Also a lot of other problems here.return async function()
does not do what you seem to think it does, and it's not really clear here what you are expecting. Needs more context as well as some basic debugging.
– Neil Lunn
Nov 12 '18 at 8:52
I know that response.data.keys[0] is not defined. but how can it be defined if the value is being called from an api?
– Slyckies
Nov 12 '18 at 12:30
add a comment |
2
response.data.keys[0]
has a "property 0", so the error implies thatkeys
there is not actually defined. Also a lot of other problems here.return async function()
does not do what you seem to think it does, and it's not really clear here what you are expecting. Needs more context as well as some basic debugging.
– Neil Lunn
Nov 12 '18 at 8:52
I know that response.data.keys[0] is not defined. but how can it be defined if the value is being called from an api?
– Slyckies
Nov 12 '18 at 12:30
2
2
response.data.keys[0]
has a "property 0", so the error implies that keys
there is not actually defined. Also a lot of other problems here. return async function()
does not do what you seem to think it does, and it's not really clear here what you are expecting. Needs more context as well as some basic debugging.– Neil Lunn
Nov 12 '18 at 8:52
response.data.keys[0]
has a "property 0", so the error implies that keys
there is not actually defined. Also a lot of other problems here. return async function()
does not do what you seem to think it does, and it's not really clear here what you are expecting. Needs more context as well as some basic debugging.– Neil Lunn
Nov 12 '18 at 8:52
I know that response.data.keys[0] is not defined. but how can it be defined if the value is being called from an api?
– Slyckies
Nov 12 '18 at 12:30
I know that response.data.keys[0] is not defined. but how can it be defined if the value is being called from an api?
– Slyckies
Nov 12 '18 at 12:30
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258512%2fnode-js-self-callback-apply-is-not-a-function-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258512%2fnode-js-self-callback-apply-is-not-a-function-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
response.data.keys[0]
has a "property 0", so the error implies thatkeys
there is not actually defined. Also a lot of other problems here.return async function()
does not do what you seem to think it does, and it's not really clear here what you are expecting. Needs more context as well as some basic debugging.– Neil Lunn
Nov 12 '18 at 8:52
I know that response.data.keys[0] is not defined. but how can it be defined if the value is being called from an api?
– Slyckies
Nov 12 '18 at 12:30