In my Nativescript project, I have the following TypeScript file:
import { Observable } from 'tns-core-modules/data/observable';
import { isIOS } from "tns-core-modules/platform";
import { Color } from "tns-core-modules/color";
import { request, getFile, getImage, getJSON, getString } from "tns-core-modules/http";
export class HomeViewModel extends Observable {
items: {
name: string,
desc: string,
price: string,
imageSrc: string,
}[];
getData = getJSON("http://localhost:3000/items").then((r: any) => {
this.getData = r; // Assign data from response on success
console.log("blarg!!!")
}, (e) => {
});
onItemLoading(args) {
if (isIOS) {
var newcolor = new Color("#e6e6e6");
args.ios.backgroundView.backgroundColor = newcolor.ios;
}
}
constructor() {
super();
}
}
I am facing an issue where the getData function is not being called or executed. How can I trigger the execution of getData function?