TylerRosen
2/14/2017 - 12:49 AM

Server Questions

//1. fill in the blanks:
//client makes requests to the server
//server gives a response to the client

app.get("/dogs/:name", function(req, res) {
  //2. how do I access :name here?
  req.params.name

});

//3. If this code is actively running on port 3000, write the client side JavaScript to be able to get this data and display it on the screen (no need to write html)
app.get("/dogs", function(req, res) {
  res.json([
    {name: 'max',
      age: 2 },
    {name: 'repunsel',
      age: 3 }
    ])
});

$.ajax({
    method: 'GET',
    url: '/dogs
}).done(function(data){
    $(body).html(JSON.stringify(data));
});