I have never worked with Dango Api.I am also new to node.js.I am trying to hit a link (Route) of my Laravel app with my Node.js.I am using Dango Api in my Laravel app.I heve tried to show data to the UI (node.js port) and print that data to console.But i am getting blank page in the screen and 'Undefined" in console.I am totally new in API.So,i don't even know if it will work.So please pardone me if this question is not appropriate as per the standard of this community.
Here is my api route-
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
$api->get('/',function(){
$user= User::where('id',1)->findOrFail();
return response()->json($user);
});
});
Here is my Node.js File:
var express = require('express');
var app=express ();
app.get('/api', function (req, res) {
res.send(req.user);
console.log(req.user);
})
var server = app.listen(8081, function () {
var host = 'localhost'
var port = 8000
console.log(host,port);
})
Now,I am getting this error on the localhost:8081
Cannot GET /