How I add Headers to http.get or http.post in Typescript and angular 2?

后端 未结 4 2089
后悔当初
后悔当初 2020-12-16 11:35
getHeroes (): Observable {
    return this.http.get(this.heroesUrl)
      .map(this.extractData)
      .catch(this.handleError);
  }

4条回答
  •  清酒与你
    2020-12-16 12:09

    if someone facing issue of CORS not working in mobile browser or mobile applications, you can set ALLOWED_HOSTS = ["your host ip"] in backend servers where your rest api exists, here your host ip is external ip to access ionic , like External: http://192.168.1.120:8100

    After that in ionic type script make post or get using IP of backened server

    in my case i used django rest framwork and i started server as:- python manage.py runserver 192.168.1.120:8000

    and used this ip in ionic get and post calls of rest api

提交回复
热议问题