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

前端 未结 10 821
广开言路
广开言路 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:01

    I did face this issue and in my case responseType suppose to be text (because of designed API end-point) rather than default json.

    import { HttpClient } from '@angular/common/http';

    Before:

    getToken(tokenCommand) {
        return this.http.post(API_BASE_URL + 'user/token', tokenCommand);
    }
    

    After fixed:

    getToken(tokenCommand) {
        return this.http.post(API_BASE_URL + 'user/token', tokenCommand
                                                         , { responseType: 'text' });
    }
    

    I think this error message is too general and it will be nice if it's developers could provide more detail/helpful error message. Thanks.

提交回复
热议问题