The network request fetch method in React native is the simplest, but it can implement most network requests and need to know more access:
1190000003810652
/** * Sample React Native App * https://github.com/facebook/react-native * Week less stop 2016-09-28 * Fetch request Data Header parameter response to J Son request Way */import React, {Component} from ' React '; import {appregistry, StyleSheet, Text, View, Touchableop Acity} from ' react-native '; var Project = React.createclass ({render () {return (<view style={styl es.container}> <touchableopacity onpress={this.ssss}> <Text> visit </TEXT&G T </TouchableOpacity> </View>); }, SSSs () {fetch (' http://www.pintasty.cn/home/homedynamic ', {method: ' POST ', headers: {/ /header ' token ': ' EYJ0EXAIOIJKV1QILCJHBGCIOIJIUZI1NIJ9.EYJ1C2VYSWQIOIJVLTLIZGJHNJBJMJZIMDQWZGJIMTMWYWRHYWVL N2fkytg2iiwizxhwaxjhdglvblrpbwuioje0nzuxmtg4odu4ntd9.imbjxrfydnyfptk2_q2jffb2rc5dhtzszophg_daunu '}, Body:JSON.stringify ({//Parameter ' start ': ' 0 ', ' Limit ': ' + ', ' isneedcategory ': true, ' lastrefreshtime ': ' 2016-09-25 09:45:12 ' }). Then ((response) = Response.json ())//convert response to JSON. Then (ResponseData) = = {//top-up JSON alert (responsedata);///Console.log (ResponseData); }). catch (Error) = {alert (' wrong '); })}); Const styles = Stylesheet.create ({container: {flex:1, justifycontent: ' Center ', align Items: ' Center ', backgroundcolor: ' #F5FCFF '}}); Appregistry.registercomponent (' Project ', () = project);
Full source Download: https://github.com/pheromone/React-Native-1
React network requests in the native