javascript - Retain JSON data after get request in Typescript -


i'am trying call rest api distant server retrieve usefull data. data meant injected in angular2 linechart.

i manage retrieve json file , cast custom interface.

my interface generated json2ts.com

my interface generated json2ts.com

here constructor , linechart variables fill json data. in constructor cast json result in interface type: rootobject when printing json value in console value valid.

here constructor , linechart variables fill request json data. when printing json value in console value valid

i can t assign value data gather json file or error of type : cannot read property 'linechart' of undefined

i can t assign value data gather json file

the problem can't set class data variable constructor, or directly set data chart. way set

any appreciated.

try async

var me = this;  this.http.get('url').map((res:any)=>{  let data = ..... me.data = data }) return me.data; 

Comments