zoukankan      html  css  js  c++  java
  • React-Native post和get请求

    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   },
  • 相关阅读:
    HashMap
    java反射
    arraylist和linkedlist区别
    int和Integer的区别
    java 数组排序并去重
    矩阵链乘法问题
    找零问题
    硬币收集问题
    最大借书量问题
    钢条切割问题
  • 原文地址:https://www.cnblogs.com/weifengzz/p/5144528.html
Copyright © 2011-2022 走看看