Currently, I am facing a challenge with my Angular 4 app integrated within Electron and using express.js to fetch data from MongoDB. My dilemma lies in the communication process with express through http requests.
Within my angular service, there is a method designed to retrieve all player data.
dataUrl: string = "/api/player/all";
getPlayers(): Observable<any> {
return this.dataService.getCookedData(this.dataUrl, this.finalizePlayerData); //this function works fine in a regular web browser.
}
In my express.js setup, the API endpoint has been created as follows:
router.get('/all', (req: Request, res: Response) => {
player.find().then((result) => {
res.send(result);
});
});
However, my application is experiencing a 404 error with the following message:
zone.js:1980 GET file:///api/player/all net::ERR_FILE_NOT_FOUND
I am aware that the issue stems from file:///
instead of http://
, but I am uncertain about how to rectify this. Any suggestions or guidance?