Skip to content

NextChampion/react-native-networkrequest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-networkrequest

You can install the latest beta with

npm i react-native-networkrequest --save
This component has the function of the request timeout, and support requests timeout callback, can avoid repeating same requests.

Preview

Getting start

start with

npm i react-native-networkrequest --save

Usage

import * as networkRequest from 'react-native-networkrequest'
fetch(){
      a++;
    console.log('a==='+a);
    if (!loading) {
      loading = true
      b++;
      console.log('b==='+b);
      var url1 = 'http://192.168.0.125:8080/paike_service/tour/getTourList/userName/13269661186/model/1'
      var url = 'http://api.ycapp.yiche.com/media/getnewslist?pageindex=1&pagesize=20'
      var url2 = 'http://www.baidu.com'
      var url3 = 'http://192.168.0.125:8080/v1/users/login/SunY/123456/uniway'

      ZCXNetworkRequest.post(20000,url1,null, (res)=>{
        alert('请求成功')
        console.log(res);
        loading = false
      },(timeout)=>{
        alert(timeout)
        loading = false
      },(error)=>{
        loading = false
        console.log(loading);
        alert(`网络错误,错误码:${error.status}`)
      })
    }

    // ZCXNetworkRequest.get(20000,url,(res)=>{
    //   alert('请求成功')
    //   loading = false
    //   console.log(res);
    // },(timeout)=>{
    //   loading = false
    //   console.log(loading);
    //   alert(timeout)
    // },(error)=>{
    //   loading = false
    //   console.log(loading);
    //   alert(`网络错误,错误码:${error.status}`)
    // })

  }

Example

Check ZCXNetworkRequestDemo folder

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published