Creating a basic Angular application to access the random users resource. Also setting up CORS on the node server to enable the resource sharing across different domains (ports in our case).
In the video Kent used a http-server in his public folder to launch his application. Is there a place in docs that explains if that is the best practice in using this method?
http-server is a node module that just serves up a directory as static files. I would not recommend using tool approach in production. Look into static file server solutions. One thing that I've done in the past that was really easy was use an amazon s3 bucket to host my frontend code. Or you could use firebase hosting, or github pages hosting, or a host of other options.
I am following the series on JWT and everything is great until I run http-server (as you do) in the /public folder. Instead of it working like it did for you, I get "zsh: command not found: http-server". I already blew everything away once and started from scratch so I am pretty sure I haven't missed a step.
I started from an empty webstorm (actually, phpStorm) project just like you did and I have installed everything just as you did.
I suspect the http-server node package needs to be installed:
npm install -g http-server
Thanks, Joel. That worked and the site launched.
I am getting a TypeError: Cannot read property 'then' of undefined for the RandomUserFactory.getUser().then
Make sure that the getUser function is returning the promise created by $http. Like so:
return $http.get(API_URL + '/random-user');
i am getting undefined for req.body.username. followed the same steps. any idea
I find it helpful to use a Docker container with an NgInx instance.
Yes, you have to learn about Docker but it is so awesome that it will be worth your while.
I always spin up a number of Docker containers as part of my development proces, it's imho invaluable.
Took a little while to figure out why I was still getting a CORS error. Realized it's important to call cors() before defining any routes. :)
Hi, in my case everything works fine, except I am only able to click the button once and get the result. Any more clicks will not get any new random user!!! Any idea how to solve this??!