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 }}!

  • {{vendor.id}}: {{vendor.Gym}} {{vendor.Counselor}} {{vendor.Park}} {{vendor.Store}} (index {{i}})
  • Output is empty web page,

    Please help with coding

    Step by Step Solution

    There are 3 Steps involved in it

    1 Expert Approved Answer
    Step: 1 Unlock blur-text-image
    Question Has Been Solved by an Expert!

    Get step-by-step solutions from verified subject matter experts

    Step: 2 Unlock
    Step: 3 Unlock

    Students Have Also Explored These Related Databases Questions!