Skip to content

Instantly share code, notes, and snippets.

@harshaktg
Created June 2, 2021 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshaktg/9339921829168dd09142a59f77dd2de3 to your computer and use it in GitHub Desktop.
Save harshaktg/9339921829168dd09142a59f77dd2de3 to your computer and use it in GitHub Desktop.
useAxios - Step 4
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