0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Angular HTTPでjson以外を受け取るときにERROR Parsingになる対処

Posted at

恐らく少し調べれば分かる事なのですが、20分くらい戸惑ったのでメモ...

エラー

this.http.get('http://hoge/fuga'.subscribe(data => {
      console.log(data);
    });

=>error Parsing

解決

this.http.get('http://hoge/fuga',{ responseType: 'text' }).subscribe(data =>
{
      console.log(data);
    });

@angular/common/httpは標準でJSONとしてパースしようとするので、json以外の時はresponseTypeを
指定する必要があるらしい.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?