I'm working on a school project where we have to create an app. One page contains true/false questions that the professor provides and the students can answer. The page is done, except for the http request to get the questions and answer keys. I'm currently mocking the server with postmann. A request to the provided link from postmann works.
However, I always get JSON parsing erros...
This is of the JSON Strings I tried to used
{
„question“ : „what is 2x2?“ ,
„answerKey“ : true
}
And this is the error message I get:
SyntaxError: "JSON.parse: expected property name or '}' at line 2 column 1 of the JSON data"
The Question class has two attributes:
answerKey: boolean;
and
question: string
And below you can see my http.get function and the function that calls the get function
public getAllQuestions(): Observable<Question[]> {
return this.http.get<Question[]>(this.baseurl.concat('quiz'));
}
public pullQuestionFromBackend(): void {
this.submitQuizService.getAllQuestions().subscribe((question: Question[]) => {
this.questionList = <Question[]> question;
});
}