Creating the basic node server to serve up random users via API endpoints.
Man 1: [00:00] This is "Authentication with AngularJS, Getting it Right with JWT." That's pronounced "Jot".
[00:07] We're going to create a basic server that will server up a random user and then create a front end client that will consume this service to illustrate how to do authentication with JWTs.
[00:21] First of, we're going to need our JavaScript file. We'll call that Server js. A couple of things that we're going to need through NPNR, Express and Faker.
[00:33] Faker's how we're going to make the random user. We're going to require Express and we'll require Faker. Then we'll create our app. Then we'll have our app and have a get on random user with the request and response.
[00:52] We'll save our "User = faker.Helpers.userCard" and "user.avatar = faker.Image.avatar." Then we'll say response send back the user as JSON. Then I will have our app listen on port 3000. We'll just say, "App listening on localhost:3000."
[01:17] We're going to use nodemon to have our server automatically restart every time we make changes so nodemon server js.
[01:29] Here we'll go to local host:3000. Obviously we can't get a route but we can get random user. Here every time we refresh we have a random user.
var user = faker.helpers.userCard(); user.avatar = faker.image.avatar();
Yeah, that helps! I think that needs to be mentioned somewhere in lesson
What editor are you using?
In this video I'm using Webstorm, but I use Atom these days: https://github.com/kentcdodds/ama/issues/113
I found that the 'case' has changed to lowercase on faker.Helpers and faker.Image.
The code as presented did not work for me until I changed it to:
var user = faker.helpers.userCard(); user.avatar = faker.image.avatar();