This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ChangeEvent } from 'react'; | |
import { useSearchParams } from 'react-router-dom'; | |
// Temporary key of my query parameter | |
const MY_QUERY_PARAMETER: string = 'myQueryParameter'; | |
export const UpdateQueryParameters = (props: any) => { | |
// Hook which returns a tuple. First element is the current URLSearchParams object and second element is the function to take in the new URLSearchParams object alongside a configuration object to either replace the query parameters or not alongside state. | |
const [currentQueryParameters, setSearchParams] = useSearchParams(); | |
const newQueryParameters : URLSearchParams = new URLSearchParams(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from, of, Observable, forkJoin } from 'rxjs'; | |
import { map, switchMap, tap } from 'rxjs/operators'; | |
// I have made a token service. which exposes | |
// setAccessToken, setRefreshToken, getRefreshToken, getAccessToken methods interacting with browser localStorage. Feel free to change as per your application architecture | |
import { tokenService, userService } from './tokenService'; | |
// high level flag to prevent getting into refreshing mode again. | |
let IS_REFRESHING: boolean = false; | |
export const refreshTokenInterceptorCustomFetch = (uri: RequestInfo, intitalOptions: RequestInit): Promise<Response> => |