How to check whether user is present in the database or not using Angular

Discussão em 'Angular' iniciado por Naushadsuleman Khan, Fevereiro 13, 2025.

  1. I stuck in writing the logic to check whether the user presents in the database or not...

    Here I am sharing the important information regarding my problem for better understanding.

    1. My API Link :

    http://localhost:8081/Metadata/api/user/IsValidUser

    1. Postman, post JSON request

    {

    "Contact_No" : 9876543210,
    "Password" : "pass@12345"
    }


    Here in postman, I am writing the data manually. but for actual data, I have created the login form in angular 3. Now it will check the above data is present in the database or not. If present then I will get the below information.

    Login screen screenshot

    {
    "program": null,
    "version": null,
    "dateTime": null,
    "success": true,
    "errorCode": null,
    "errorMessage": null,
    "message": "User Authenticated Successfully",
    "data": {
    "mobile_No": 9876543210,
    "isValid": true,
    "pSNL": {
    "first_Name": "First",
    "middle_Name": "",
    "last_Name": "Buyer",
    "address": null,
    "village": "Airoli",
    "taluka": "Thane",
    "district": "Thane",
    "state": "Maharashtra",
    "pincode": 400708,
    "email": "test@test.com",
    "dob": "06-01-1999"
    }
    }
    }

    1. I wrote the service in angular, but I think its required password parameter as well I am a little confused here. Like how to write a Post request with two parameters.

    IsValidUser(validUser : IsValidUserModel){
    console.log("Calling IsValidUser API " + validUser.Contact_No);
    return this.http.post("/Metadata/api/user/IsValidUser", validUser)

    }


    1. IsValidUserModel.ts

    export class IsValidUserModel {

    Contact_No: number
    Password: string
    }


    Now let me summarized my query, All I want to make check whether the user is present or not in the database. But I am confused about how to do the implementation. Can anyone suggest to me the best way to implement my problem or how to tackle the type of challenge in angular? I hope my question is clear.

    Continue reading...

Compartilhe esta Página