0

I have a little problem, I can't get the data via the link web enter image description here

I use Angular5

ratp.service.ts

getDatas(){
    const url = "https://data.ratp.fr/explore/dataset/liste-des-commerces-de-proximite-agrees-ratp/api/?disjunctive.code_postal&sort=code_postal&refine.tco_libelle=Le+Narval";
    const headers = new HttpHeaders()
       .append('Content-Type', 'application/json')
       .append('Access-Control-Allow-Origin', '*')
       .append('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, authorization,Client-Security-Token')
       .append('Access-Control-Allow-Methods', 'GET, PUT, POST, PATCH, DELETE, OPTIONS');

    return this.http.get<any>(url,{headers} ).pipe(map(res => console.log(res)));
}

app.component.ts

test(){
   this.ratp.getDatas().subscribe(res => res);
}

app.component.html

<button (click)="test()">Click</button>
  • See answers for https://stackoverflow.com/questions/10883211/deadly-cors-when-http-localhost-is-the-origin/10892392 or https://serverfault.com/questions/102416/iptables-equivalent-for-mac-os-x/673551#673551 – Will Oct 29 '18 at 16:05

1 Answers1

2

you're not hitting a rest endpoint. your endpoint should look like something like below:

https://data.ratp.fr/api/records/1.0/search/?dataset=liste-des-commerces-de-proximite-agrees-ratp&lang=fr&rows=2&facet=tco_libelle&facet=code_postal&refine.tco_libelle=Le+Narval

where the base url is https://data.ratp.fr/api/records/1.0/search/

kyamaz
  • 146
  • 1
  • 6