I'm having trouble with a .net core SPA app. - Results are being passed back by the API call - the SPA is not handling the results.
here is the pertinent code:
SPA ts:
class TestLibraryItem {
private _apiPath: string;
private _http: HttpClient;
public name: string;
public testResults: TestResult;
constructor(name: string, apiPath: string, http: HttpClient) {
this.name = name;
this._apiPath = apiPath;
this._http = http;
}
RunTests() {
this._http.get<TestResult>(this._apiPath)
.subscribe(result => {
this.testResults = result;
console.log(this.testResults);
console.log(this.testResults.CheckName);
});
}
}
class TestResult {
CheckName: string;
Checks: CheckResult[];
}
class CheckResult {
Test: string;
Pass: boolean;
}
and the console results when RunTests() is fired:
{"CheckName":"Check One","Checks":[{"Test":"Test one","Pass":true},{"Test":"Test two","Pass":true}]}
undefined
As far as I can tell, I'm getting valid json back from the API (indicated by console.log spitting it out, but it is not actually building the object which results in the undefined.