2016-09-17 32 views
0

我有一个简单的想法,试图检查NetworkInterface中的afterware中的不同类型的错误。让我们假设我不能使用response.code为目的,所以我需要访问身体:AppoloStack NetworkInterface AfterWare

networkInterface.useAfter([{ 
    applyAfterware({ response }, next) { 
     // need to access response.body here 
     next(); 
    } 
}]); 

但它并没有提供response.body使用,所以我喜欢应该有另一种方式来去做?

回答

0

我知道这是旧的,但我相信,响应对象为fetch response,因此,你会做这样的事情:

networkInterface.useAfter([{ 
    applyAfterware({ response }, next) { 
     // Assuming body is a JSON object, see link for other methods 
     response.json().then(function(body) { 
      // Work with the body here 
      next(); 
     }); 
    } 
}]); 
相关问题