HttpParams doesn't work in angular getting 502 error

前端 未结 2 1300
旧巷少年郎
旧巷少年郎 2021-01-28 13:46

I am using angular 8

  • I am using HttpParams in Sending Data to the Server via Post method
  • I am getting 502 statu
相关标签:
2条回答
  • 2021-01-28 14:25

    Tried visiting the api endpoint on browser, check if the URL is correct, and maybe include access control allow origin in your header

    0 讨论(0)
  • 2021-01-28 14:25

    Im not sure but please check this......

    This Should be your service file code

    userlogin(userid, smpassword) {
    const params = new HttpParams()
    .set('user_id', userid)
    .set('sm_password', smpassword);
    console.log(params);    
    return this.http.post(this.baseUrl+'user/login',JSON.stringify(params)).pipe(map((res) => {
      return res;
    }));
    

    }

    This Should be your login.component.ts

         login() {
            const email =  this.Userlogin.get('email').value;
            const password = this.Userlogin.get('password').value;
            this.rest.userlogin(email, password).subscribe((result)=> {
            result = JSON.Parse(result)
                console.log(result);
              }
            );
    
    0 讨论(0)
提交回复
热议问题