I have a php file and Node API. The php file in server which return the random number by user given max value. The user given maximun value is given from Node Js to php. Then the php returns the random value, then the values should be save in MongoDB
php code
<?php
$min = 1111;
$max = ''; // This is given by user from Node API
$number = mt_rand($min, $max); //Generate a random number using the rand function.
echo $number;
?>
Node API
router.post("/findMax", upload.single('image'), function (req, res, next)
{
var enteredMaxNum = req.body.maxNum;
if(!enteredMaxNum)
{
return res.status(400).send("Maximum number should be given");
}
const objNumber = new Number(
{
max : enteredMaxNum, // User given, should pass to php variable
randNum : ????, // php file return value
});
objNumber.save((err) =>
{
if (err)
{
console.log("New Error : " + err);
return next(err);
}
res.status(201).send("Numbers saved");
});
})