Got api request working.
I added the necessary header to the api server and then changed the content type of the request to text/plain to disabled the preflight OPTIONS request which the server was erroring on. Not sure about the security of all this but it's a very basic website and I don't think it'll be an issue.
This commit is contained in:
parent
fbb00cdecc
commit
036f48b3f0
@ -32,13 +32,13 @@ export class ProjectsService {
|
||||
* I am actively avoiding any kind of environment management, this is a very basic site and currently this is the only api call.
|
||||
*/
|
||||
|
||||
private PROJECT_API_URL = "https://cms.inkletblot.com/"
|
||||
private PROJECT_API_URL = "https://cms.inkletblot.com/api/json"
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
httpOptions = {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'text/plain'
|
||||
})
|
||||
};
|
||||
|
||||
@ -48,7 +48,16 @@ export class ProjectsService {
|
||||
.subscribe(
|
||||
(response: Project[]) => {
|
||||
if (response) {
|
||||
this.allProjects = response;
|
||||
// using text/plain so as to not get the preflight options request
|
||||
// as such : Project[] does not work as expected and objects must be parsed.
|
||||
for (let project of response) {
|
||||
this.allProjects.push({
|
||||
title : project.title,
|
||||
description : project.description,
|
||||
ct : project.ct,
|
||||
body : project.body
|
||||
});
|
||||
}
|
||||
// filter out different categories here currently only one
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user