问题
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