2017-05-07 58 views

回答

0

你問的是不明確的。你面臨的問題是什麼?服務器響應將始終是字符串。它可以是有效的Json/xml或純文本。如果你想用它作爲JSON。

來源:https://facebook.github.io/react-native/docs/network.html

function getMoviesFromApiAsync() { 
    return fetch('https://facebook.github.io/react-native/movies.json') 
     .then((response) => response.json()) 
     .then((responseJson) => { 
     return responseJson.movies; 
     }) 
     .catch((error) => { 
     console.error(error); 
     }); 
    } 
+0

對不起,不夠清楚。我想詢問是否有一種方法僅返回「LED狀態:開/關」字符串,而沒有顯示在屏幕上的其他文本。 – Davezor

0

與子()和的indexOf()固定它。