react-request-hook
react-request-hook copied to clipboard
useResource not accepting configuration
I have a ReactJS project created using the create-react-app utility and I've setup react-request-hook as follows.
Only index.jsx (P.S no App.jsx):
const axiosInstance = axios.create({
baseURL: 'http://someurl',
})
ReactDOM.render(
<RequestProvider value={axiosInstance}>
<Router />
</RequestProvider>,
document.getElementById('root'),
)
I have written a single API for login which is a POST call
const api = {
loginUser: async ({
username,
password,
language,
}) => {
return request({
method: 'post',
url: '/login',
data: {
username,
password,
language,
requestId: 'LOGIN',
},
})
},
}
And this is how I'm using it.
const [response] = useResource(api.loginUser,
[{
username: 'test',
password: 'test',
language: 'en',
}])
When I run the react app, a request is made only to the base URL and the request type is 'GET" Looks like my data or URL is not accepted as an argument along with the Axios config instance.
Any ideas on what I'm doing wrong? @schettino
Did you figure it out how to fix it, @samithbharadwaj ?
@oldmember No, I couldn't figure it out. Any ideas?