React network requests in the native

Source: Internet
Author: User

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 &LT;/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

Related Article
Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.