-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1004 from oraichain/feat/detail-proposal
fix: detail proposal
- Loading branch information
Showing
3 changed files
with
107 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useState, useEffect } from "react"; | ||
import config from "../config"; | ||
import axios from "axios"; | ||
|
||
const lcdApi = config.LCD_API; | ||
|
||
export default function useFetchLCD(url) { | ||
const [result, setResult] = useState({}); | ||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState(); | ||
|
||
useEffect(() => { | ||
async function fetchData() { | ||
try { | ||
const response = await axios.get(`${lcdApi}/${url}`); | ||
if (!!response) { | ||
const data = response.data; | ||
setResult(data); | ||
} | ||
} catch (error) { | ||
setError(error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
} | ||
fetchData(); | ||
}, []); | ||
|
||
return { | ||
result, | ||
loading, | ||
error, | ||
}; | ||
} |