Setting up Angular 14 Node authentication backend

Setting up Angular 14 Node authentication backend

In this step, we'll clone the Node authentication backend from GitHub and run it locally.

Head back to a new command-line interface and run the following command:

$ git clone https://github.com/techiediaries/node-mongodb-jwt-authentication.git node-mongodb-authentication-backend

Next, navigate to the project's folder and install the dependencies then start the server as follows:

$ cd node-mongodb-authentication-backend
$ npm install
$ npm start

The Node server will be available from http://localhost:4000/.

Next, you also need to run the mongod client. Open a new command-line interface and run:

$ mongod

These are the API endpoints that are exposed from the Node server:

  • POST /users/login
  • POST /users/register
  • GET /users/profile/id
  • PUT /users/update/id
  • DELETE /users/delete/id

Step 5 - Setting up Angular 14 HttpClient

In this step we'll import and set up HttpClient in our Angular project.

Open the src/app/app.module.ts file, import HttpClientModule and add it the imports array as follows:

import { HttpClientModule } from '@angular/common/http';

@NgModule({
  imports: [
    HttpClientModule
   ]
})

See you in the next tutorial


  • Date: