The example I provided should work without any extra imports (RestProvider) not required.
This is how I get json data from a file within the assets folder.
buildData(){
var xx = this;
let promise = new Promise((resolve, reject) => {
this.http.get('assets/data/vocab.json').map(res => res.json()).subscribe(data => {
xx.mainData = data;
xx.getotherdata();
resolve();
})
});
return promise;
}
I think the code your are using the data returned might be an object - just do a console.log(to view it). I have a hunch it might this.datas = data.data
The code posted above had like 4 anti-patterns in it. Do not attempt anything inside it.
Put a break point in your subscribe and see what data is. If it’s json you need json.parse to turn it from a string into an array (although the"json" you posted looks invalid because there are no array brackets around it.
I’m assuming your date strings there are year month day, I could be wrong. Also you could still get timezone issues from this, it may be worth it for you to use a date library. However, you possibly want something like this: https://jsfiddle.net/po8a111o/11/
This also shows parsing the json into a javascript array if you need it.
EDIT: If you can’t figure it out from this you need to post your restProvider.getJson method, because as it stands there is no way anyone could ever know what data you are actually working with