Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options => {
let didCancel = false;
const apiOptions = !!options
? {
...args.options,
...options
}
: args.options;
dispatch({ type: "FETCH_INIT" });
(apiOptions.useMockData && apiOptions.mock
? fetchMockData(apiOptions.mock, apiOptions)
: fetchJson(
queryString.stringifyUrl({
url: urlJoin(apiOptions.baseApiUrl, endpoint),
// query params supplied via `apiOptions` have a higher priority
// and will override query param with the same name if it is
// present in the `endpoint`
query: apiOptions.query
}),
args.authCtx,
apiOptions
)
)
.then(result => {
if (!didCancel)
dispatch({
type: "FETCH_SUCCESS",
payload: result.body,
headers: result.headers
export const formatUrl = (url: string, query?: any): string =>
queryString.stringifyUrl({ url: url, query: query });