Skip to content

Instantly share code, notes, and snippets.

View degitgitagitya's full-sized avatar
😀
Hello. World.

De Gitgit Agitya degitgitagitya

😀
Hello. World.
View GitHub Profile
import usePlayerStore from '../hooks/use-player-store/use-player-store';
import { useCallback } from 'react';
export function UsePlayer() {
const { audio, setAudio, state, setState, updateTime, updateDuration } =
usePlayerStore();
const preLoad = useCallback(
(url: string) => {
@degitgitagitya
degitgitagitya / ErrorHandler.ts
Created July 27, 2021 05:53
Clean Promise Handler
/**
* @param {Promise<T>} promise
*/
export const resolvePromise = async <T>(promise: Promise<T>) => {
try {
const data = await promise;
return [data, null] as const;
} catch (error) {
return [null, error] as const;
}
@degitgitagitya
degitgitagitya / Api.ts
Last active June 21, 2022 12:33
Clean Error Handler For Axios (Typescript)
import Axios, { AxiosRequestConfig } from 'axios';
import { resolveErrorBackEnd, resolvePromise } from '../ErrorHandler';
const someApiCall = async () => {
const requestConfig: AxiosRequestConfig = {
headers: {
Authorization: ``,
},
};
const [data, error] = await resolvePromise<PaginatedConversation>(
@degitgitagitya
degitgitagitya / .env
Last active November 4, 2024 06:43
Next JS + Next Auth + Keycloak + AutoRefreshToken
# KEYCLOAK BASE URL
KEYCLOAK_BASE_URL=
# KEYCLOAK CLIENT SECRET
KEYCLOAK_CLIENT_SECRET=
# KEYCLOAK CLIENT ID
KEYCLOAK_CLIENT_ID=
# BASE URL FOR NEXT AUTH