Angular http.post-json返回null

时间:2019-01-24 22:47:44

标签: javascript angular

我需要帮助。为什么用json发送表单到php api发送null值? 代码是我的auth.service.ts和php API,我从登录表单发送数据。

    $post = file_get_contents('php://input');

    $data = json_decode($post);

    $login = $data->login;  -- here is null 
    $haslo = $data->pass;

logIn(credentials: Credentials): Observable<boolean> {
    return this.http.post(`${this.API_URL}/auth`,JSON.stringify({"login": credentials.login, "pass": credentials.pass}),{ headers: { 'Content-Type': 'application/json' }).pipe(
      map(res => {
        if(res['token'] == 1) {
          return true;
        } else {
          return false;
        }
      })
    )
  }

0 个答案:

没有答案