Angular 4 proper way to cast http response

后端 未结 3 1173
自闭症患者
自闭症患者 2021-01-17 05:03

I\'ve created a service in Angular 4 and I\'m fetching data via REST/JSON (new to Angular) using this code:

Interface

export interface IItem {
    Id         


        
3条回答
  •  感情败类
    2021-01-17 05:30

    You'd probably want to run a few mapping utilities

    http.get(url)
    .map(response => response.json())
    .map(response => response.d.results)
    .map(results => results.map(item => return Object.create(IItem, item))
    

提交回复
热议问题