Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => alert('fetch end'))
.catch(e => alert(e));
},
})),
);
const Button403 = ({ handleClick }) => (
<button type="button">
Simulate 403
</button>
);
const Button403Enhance = enhance403(Button403);
const enhanceFetch = compose(
withAuthentication(fetch),
withProps(props => ({
handleClick: e => {
e.preventDefault();
props
.fetch('http://localhost:3000/')
.then(() => alert('fetch end'))
.catch(e => alert(e));
},
})),
);
const ButtonFetch = ({ handleClick }) => (
<button type="button">
Simulate Fetch
</button>
);
}
});
const withFetch = withHandlers({
getProjects: props => async () => {
const response = await props.fetch(getProjectsUrl);
if (response.status !== 200) {
throw response.statusText;
}
return response.json();
}
});
export default compose(
projectsState,
withAuthentication(fetch),
withFetch,
lifecycleHoc
)(Component);
import { withAuthentication } from '@axa-fr/react-oidc-context-fetch';
const fetchMock = status => (url, options) => {
return new Promise(resolve => {
setTimeout(
() =>
resolve({
status,
}),
350,
);
});
};
const enhance401 = compose(
withAuthentication(fetchMock(401)),
withProps(props => ({
handleClick: e => {
e.preventDefault();
props
.fetch('http://www.demo.url')
.then(() => alert('fetch end'))
.catch(e => alert(e));
},
})),
);
const Button401 = ({ handleClick }) => (
<button type="button">
Simulate 401
</button>
);
this.props.displayMessage(error);
}
}
});
const withContext = fromRenderProps(
MessageContext.Consumer,
({ displayMessage }) => ({ displayMessage })
);
const withBranch = hideIfNotData => branch(hideIfNotData, renderNothing);
export default compose(
usersState,
withContext,
withAuthentication(fetch),
withFetch,
lifecycleHoc,
withBranch(({ users }) => !users || users.length === 0)
)(Component);