Discussions

Ask a Question
Back to All

Problem with webhook integration in Nodejs

I have added the below code and installed the jsonwebtoken package as well. After running the code , its throwing error "ReferenceError: Orders is not defined" .

const jwt = require('jsonwebtoken');

Orders.transakWebhook = function (body, next) {
let accessToken = 'eyJhbGciOiJIUzI1NiuuuunR5cCI6Ikkjdhfkadjjjjjj.eyJBUElfS0VZIjoiNzNhYTk4ZTQtYTlhMC00YzEwLTk5MWItNjZlMTAyYmI3ZmFkIiwiaWF0IjoxNjk3NzkxMjE2LCJleHAiOjE2OTgzOTYwMTZ9.LNQT-BlhdKy6LukgCCSCsD4D_tQzVuvAr7xjrDKZiok';
let decodedData = jwt.verify(body.data, accessToken);
};

Orders.remoteMethod('transakWebhook', {
description: 'Transak WebHook',
accepts: [{arg: 'data', type: 'object', required: true, http: {source: 'body'}}],
returns: {arg: 'response', type: 'object'},
http: {path: '/webhook', verb: 'post'},
});

//output given below:-

Orders.transakWebhook = function (body, next) {
^

ReferenceError: Orders is not defined
at Object. (/home/nirajkumar/Public/PROJECTS/transak/webhook.js:3:1)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47

ο»Ώ