Question
app.js const express = require('express'); const app = express(); // use the following code on any request that matches the specified mount path app.use((req, res,
app.js
const express = require('express');
const app = express();
// use the following code on any request that matches the specified mount path
app.use((req, res, next) => {
console.log('This line is always called');
res.setHeader('Access-Control-Allow-Origin', '*'); //can connect from any host
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, OPTIONS'); //allowable methods
res.setHeader('Access-Control-Allow-Headers', 'Origin, Content-Type, Accept');
next();
});
app.get('/vendors', (req, res, next) => {
const vendors =
[{ "Vendor id":"1","Gym" : "LA Fitnes", "Counselor" : "Dr George Warsaw" , "Park" : "Bryson Park" ,"Store":"Walgreens"},
{"Vendor id":"2", "Gym" : "Snap Fitness", "Counselor" : "Dr Kelly Lewis-Arthur" , "Park" : "Stone-Mountain","Store":"Kroger" },
{"Vendor id":"3", "Gym" : "Planet Fitness", "Counselor" : "Dr Vicki Smith" , "Park" : "Oakdale Park","Store":"Walmart"},
{"Vendor id":"4","Gym":"Anytime Fitness","Counselor":"Dr Keith Hill","Park":"Swift Cantrell Park","Store":"Publix"}];
//send the array as the response
res.json(vendors);
});
//to use this middleware in other parts of the application
module.exports=app;
app.component.html
Welcome to {{ title }}!
Output is empty web page,
Please help with coding
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started