Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

    Step: 1

    blur-text-image

    Get Instant Access to Expert-Tailored Solutions

    See step-by-step solutions with expert insights and AI powered tools for academic success

    Step: 2

    blur-text-image

    Step: 3

    blur-text-image

    Ace Your Homework with AI

    Get the answers you need in no time with our AI-driven, step-by-step assistance

    Get Started

    Recommended Textbook for

    Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

    Authors: Michael F. Worboys ,Anna F. Grundy

    1993rd Edition

    3540569219, 978-3540569213

    Students also viewed these Databases questions