Passing Parameters with axios in react-native android app

旧时模样 提交于 2019-12-11 02:21:30

问题


I require to pass some parameters with AXIOS in react-native but don't know how should I pass parameters with AXIOS.

I found this post useful but its not fully satisfy my issue. I need to pass below parameters to fetch all items from API:

Working example in PHP:

$url = 'https://APISITE.net/api/Stock/GetStockItems?keyWord=6666777788889&locationId=""&entriesPerPage=10000&pageNumber=1&excludeComposites=true';

Its working well in PHP TEST file and i only need to pass keyword value ie 6666777788889 to get data.

I dont know how to pass these values in AXIOS. Please guide.


回答1:


You need to specify params in the config of axios request.

axios.get('https://APISITE.net/api/Stock/GetStockItems', {
    params: {
        keyWord: 666677788899,
        locationId: 2,
        entriesPerPage: 100000,
        pageNumber: 1,
        excludeComposites: true,
        //add other params
    }
})

You can check axios's github Readme page for reference.



来源:https://stackoverflow.com/questions/48395471/passing-parameters-with-axios-in-react-native-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!