标签:
post:
1 fetchData (title) { 2 fetch(REQUEST_URL, { 3 method: ‘POST‘, 4 headers: { 5 ‘Accept‘: ‘application/json‘, 6 ‘Content-Type‘: ‘application/json‘ 7 }, 8 body: JSON.stringify({ 9 email: un, 10 password: pw 11 }) 12 }) 13 .then((response) => response.json()) 14 .then((responseData) => { 15 if (responseData[‘isOK‘]===‘ok‘) { 16 ToastAndroid.show(‘登录成功‘, ToastAndroid.SHORT) 17 } else { 18 ToastAndroid.show(‘登录失败‘, ToastAndroid.SHORT) 19 } 20 }) 21 .done() 22 }
1 responseData (response) { 2 return response.result.data 3 }
get:
1 fetchData: function () { 2 fetch(REQUEST_URL) 3 .then((response) => response.json()) 4 .then((responseData) => { 5 this.setState({ 6 dataSource: this.state.dataSource.cloneWithRows(responseData), 7 loaded: true 8 }) 9 }) 10 .done() 11 },
标签:
原文地址:http://www.cnblogs.com/weifengzz/p/5144528.html