TypeError: You provided 'undefined' where a stream was expected

前端 未结 10 779
广开言路
广开言路 2021-01-11 09:42

I have an Ionic app that has a user provider with a signup() method:

doSignup() {
  // set         


        
10条回答
  •  感情败类
    2021-01-11 10:22

    Resolved here the right way :)

    I have been facing this issue when trying to authenticate a user using JSON Web Token. in my case it's related to authentication interceptor.

    Sending a request to authenticate a user doesn't have to provide a token since it doesn't exist yet.

    Check that your interceptor include this:

    if (req.headers.get('No-Auth') == "True")
                return next.handle(req.clone());
    

    And that you provide {'No-Auth':'True'} to your header's request like this:

      authenticateUser(user): Observable {
        const headers = new HttpHeaders({'No-Auth':'True'});
        headers.append('Content-Type', 'application/json');
        return this.httpClient.post(`${this.apiEndpoint}/auth/authenticate`, user, {headers: headers});
      }
    

提交回复
热议问题