form example with react typescript as client, and express as server
form example with react typescript as client, and express as server
// fetch example
fetch('/api/hello').then(res => res.json()).then(json => {
console.log('parsed', json);
}).catch(ex => {
throw new Error(ex);
});
// async await
async function fetchApi(url: string) {
const datas = await fetch(url).then(res => res.json());;
}
fetchApi('/api/hello');
link: https://github.com/piotrwitek/react-redux-typescript-guide#create-store
declare const window: Window & { devToolsExtension: any, __REDUX_DEVTOOLS_EXTENSION__: any };
const store = createStore<StoreState>(
reducers,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);