useEffect and load async data in React
I spent a lot of time to understand how to get async data from web-services and to set it to vars in React
I need to try to change 'fetch' to 'axios'
const host = 'https://localhost:7245/api/MySrv/'; //returns the array of data
const [items, setItems] = useState({});
useEffect( () => {
async function sendRequest() {
try {
const response = await fetch(host);
const json = await response.json();
setItems(json.map( x=> x.title));
}
catch (err) {
console.log(err)
}
};
sendRequest()
}, [])
To display use in 'return' this string:
<div>{JSON.stringify(items)}</div>
Net 10.0 is not available for Azure Functions. How to fix
Custom Label with multiple styles in TextField of Fluent UI
First impressions after using the new SPFX 1.22.2 with Heft