I have an error in the web page, but it works in postman

Discussão em 'Angular' iniciado por Roxana, Fevereiro 14, 2025.

  1. Roxana

    Roxana Guest

    I want to make a login page, but I keep having problems. If I enter my email and password in the post, it shows my username in json format. So I think the problem is from Angular,not from java

    [​IMG]

    i have this

    {path: 'authenticate', component: LoginComponent}


    login(credentials: { email: string; parola: string }) {
    return this.http.post('/authenticate', credentials, { withCredentials: true });
    }


    login(){
    const credentials = { email: this.loginForm.value.email, parola: this.loginForm.value.parola };
    this.service.login(credentials).subscribe();
    }


    { "/api/authenticate": { "target": "http://localhost:8083/api", "secure": false, "changeOrigin": true, "logLevel": "debug" } }


    i tried this

    login(credentials: { email: string; parola: string }) {
    return this.http.post<{ message: string }>("/authenticate", credentials, {
    withCredentials: true
    });


    login(email: string, parola: string): Observable<User> {
    return this.http.post<User>(
    '/authenticate', // Schimbă portul la cel corect al backend-ului
    { email, parola }
    );
    }


    login() {
    const email = this.loginForm.value.email;
    const parola= this.loginForm.value.parola;

    this.service.login(email, parola).subscribe({
    next: (user: User) => {
    console.log('Autentificare reușită:', user);
    // Poți să faci ceva cu datele utilizatorului (de exemplu, să le salvezi în aplicație)
    },
    error: (error: any) => {
    console.error('Eroare la autentificare:', error);
    // Poți să gestionezi erorile, cum ar fi afișarea unui mesaj de eroare
    }
    });}


    I don't understand what exactly I'm not doing well. I think I keep repeating a mistake of not being able to do it correctly, but I don't know exactly what.

    Continue reading...

Compartilhe esta Página