Created
August 9, 2021 14:55
-
-
Save chunleng/a6f857f2b008cff7079948f96a98b94c to your computer and use it in GitHub Desktop.
Medium: OpenAPI and CodeGen - React
This file contains hidden or 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 React from "react"; | |
import { Bar, FirstApi } from "./gen/api"; | |
function App() { | |
const [bar, setBar] = React.useState<Bar>({}) | |
React.useEffect(() => { | |
new FirstApi(undefined, "http://localhost:8000").getFoo().then((res) => { | |
setBar(res.data); | |
}); | |
}, []) | |
return <ul>{bar.items?.map(x => <li key={x}>{x}</li>)}</ul> | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment