@nooks_seo/use-axios
v1.2.0
Published
React Hook to fetch data using Axios with ease.
Readme
@nooks_seo/use-axios
React Hook to fetch data using Axios with ease.
설치
npm install @nooks_seo/use-axios
# 또는
yarn add @nooks_seo/use-axios##사용 방법
import React from "react";
import useAxios from "@nooks_seo/use-axios";
function App() {
const { loading, error, data, refetch } = useAxios({
url: "https://yts.mx/api/v2/list_movies.json"
});
if (loading) return <h1>Loading...</h1>;
if (error) return <h1>Error occurred: {error.message}</h1>;
return (
<div>
<h1>{data.status}</h1>
<button onClick={refetch}>Refetch</button>
</div>
);
}
export default App;