I m trying to communicate between PHP laravel and Node js.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://mylocalip/publish');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_PORT, 8001);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_POST, true);
$pf = array('clientId' => '123123', 'command' => '{"cmd":"start"}');
curl_setopt($ch, CURLOPT_POSTFIELDS, $pf);
curl_exec($ch);
curl_close($ch);
dd("Done");
This is what m using in php to send data, As it is sending data but on node m not getting any response, tried in angular it is responding as expected but on php side it isn't responding.
var express = require("express");
var app = express();
app.post("/publish", function(req, res) {
console.log(req, res);
console.log(req.body);
});
});
i want to get data in console that im sending from php. Is it possible that both laravel and node is currently running on localhost with different ports that's why it is not responding. If yes then how do angular is able to send data to node. Thank you,