Created
June 2, 2021 18:37
-
-
Save harshaktg/9339921829168dd09142a59f77dd2de3 to your computer and use it in GitHub Desktop.
useAxios - Step 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import useAxios from './useAxios'; | |
const App = () => { | |
const { response, error, loading } = useAxios({ | |
method: 'POST', | |
url: '/posts', | |
headers: { | |
accept: '*/*', | |
}, | |
data: { | |
userId: 7, | |
id: 777, | |
title: 'New Post', | |
body: 'This is a new post', | |
}, | |
}); | |
return ( | |
<div className="app"> | |
{loading ? ( | |
<div>Loading...</div> | |
) : ( | |
<div> | |
{error && error.message} | |
{response && response.title} | |
</div> | |
)} | |
</div> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment