I am just calling a method.
Calling method
var message = "Hello"
function1("78945612387", message, null, "Portalsms")
Node JS Code
function function1(mobileno,body,logExtraInfo,messageType){
request(uri, function (error, response, body) {
if (response) {
db.collection.insertOne(getObjectToSave(uri, mobileno, msg, logExtraInfo, messageType, error, response), function (err, result) {
if (err) {
console.log(err);
// res.status(400).send(err);
return;
}
console.log(result);
});
}
}
function getObjectToSave(uri, mobileno, msg, logExtraInfo, messageType, error, response) {
return {
"uri" : uri,
"mobileNo" : mobileno,
"message" : msg,
"logExtraInfo" : logExtraInfo,
"messageType" : messageType,
"error" : error,
"response" : response,
"creationDate": new Date()
}
}
I dont know why its giving me this error.
(Maximum call stack size exceeded )
I am not calling this function recursively.
My request call is for sending the sms,after the response i just want to store the result in my mongodb document "smsLog".
I am not using any promise here because i want this method to run asynchronous.
Thanx in advance
The problem can be resolved by:
See also this StackOverflow Q/A .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.