Lage.tech

BotmationNotes
moon indicating dark mode
sun indicating light mode

API

Getting data into React components.

Local State

import React, {useEffect, useState} from 'react';
function App() {
const [state, setState] = useState<number | undefined>();
useEffect(() => {
fetch("url").then(res => res.json()).then(res => setState(res));
}, [])
if (!state) {
return <div>...loading</div>
}
return <div>count from the api is: {state}</div>
}