Component does not receive Data from Service

后端 未结 1 1448
失恋的感觉
失恋的感觉 2020-12-22 01:29

I followed the Angular tutorial loosely and tried to receive data from a webserver, which works fine. But in the calling Component, i do not receive any data. I doublechecke

相关标签:
1条回答
  • 2020-12-22 01:48

    At your service, you should return the value:

         .then(response => {
             console.log(response.json());
             return response.json() as Project[];
         })
    

    This implicit return on arrow functions only works when the statement doesn't have curly braces. i.e:

         .then(response => response.json() as Project[])
    
    0 讨论(0)
提交回复
热议问题