I have this code:
login: any;
constructor(private http: HttpClient) { }
ngOnInit() {
this.http.get("http://localhost:8000/login/list")
.subscribe(
resultado => {
this.login = resultado;
document.write(this.login);
}
);
}
I tried to get data from a JSON located on the web and I got the data, However. when I try to get it from the localhost server (which is running a PHP application and returning JSON) it doesn't seems to work. I tried to open the URL on the web browser and it does actually return a JSON.
Any clue on what's going on?
Problem was CORS.
Adding this to my PHP project made it work:
composer req cors --ignore-platform-req=ext-http
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.