I use node.js, Firebase Functions. I try to implement a very simple function (in functions/index.js) that use POST method to get response from third party website:
exports.haveData = functions.https.onCall((data, context) => {
var $ = require('jquery');
$.ajax(
{
type: 'post',
url: 'http://example.com/info.html',
data: {
"id": data.id
},
success: function (response) {
console.log("Success !!");
},
error: function () {
console.log("Error !!");
}
}
);
return "Function ended";
});
But I have error code:
Unhandled error TypeError: $.ajax is not a function
at /workspace/index.js:35:7
at func (/workspace/node_modules/firebase-functions/lib/providers/https.js:273:32)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I cannot figure out what can be the problem... :(