I'm trying to make a GET request to this endpoint https://a.4cdn.org/boards.json of the 4chan API https://github.com/4chan/4chan-API.
The documentation says:
CORS is supported from origins boards.4chan.org or boards.4channel.org, via http:// or https://.
When I access this endpoint in my browser I get the JSON just fine but when I make a request in my Angular app I get a response back with:
headers: Object { normalizedNames: Map(0), lazyUpdate: null, headers: Map(0) }
message: "Http failure response for https://a.4cdn.org/boards.json: 0 Unknown Error"
name: "HttpErrorResponse"
ok: false
status: 0
statusText: "Unknown Error"
url: "https://a.4cdn.org/boards.json"
Here's my code:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class BoardsService {
constructor(private http: HttpClient) { }
getBoards() {
this.http.get('https://a.4cdn.org/boards.json').subscribe({
next: (data) => {
console.log(data);
},
error: (err) => {
console.log(err);
},
complete: () => {
console.log('complete');
}
});
}
}
Is anyone able to get this working?
I hope I don't need to create an API just use another API