Property does not exist on type 'string'.ts(2339)

Discussão em 'Angular' iniciado por Paul Ivan, Dezembro 18, 2024.

  1. Paul Ivan

    Paul Ivan Guest

    So here is my code and I have this error and I don't understand why. I need some help here... I don't know why is this happening : Property does not exist on type 'string'.ts(2339) at :return users.find(u => u.userName === user.userName && u.password === user.password) on u.userName and u.password . PLease help .

    import { Injectable } from '@angular/core';

    @Injectable({
    providedIn: 'root'
    })
    export class AuthService {

    constructor() { }

    authUser(user: any) {
    let users : string[] = [];
    if(localStorage.getItem('Users')) {
    users = JSON.parse(localStorage.getItem('Users') || '{}');
    }
    return users.find(u => u.userName === user.userName && u.password === user.password)
    }
    }

    Continue reading...

Compartilhe esta Página