I have this issue since I uploaded my code on hosting panel, my Database is different server and API is a different server
The error is code: "PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR", fatal: false}
it is working for some time but after calling another API then an error is occurring. Here is my code
app.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'xx.xx.xx.xx',
user : 'abc',
password : '123',
database : 'XYZ',
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
Here is the controller user.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'xx.xx.xx.xx',
user : 'abc',
password : '123',
database : 'XYZ',
})
This is one code snippet of my API.
exports.getLandLord =(req, res, next)=>{
var sql =`SELECT *FROM registrations`;
connection.query(sql, function(error, result, field){
if(error){
return res.status(201).json({message:error, status:402, success:false})
}
else
if(result.length>0){
res.status(200).json({message:"Land Loard List", status:200, success:true,
users:result,})
}
else
res.status(200).json({message:"No Record Found ", status:402, success:false, users:result})
})
}
I tried googling but I was not able to make it fix.
Please can anyone help me with this issue
Your response and help would be highly appreciated
Thanks in advance.