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 { | |
useMutation, | |
UseMutationOptions, | |
useQuery, | |
UseQueryOptions | |
} from '@tanstack/react-query'; | |
import { ITodo } from '@/type'; | |
import { |
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
export const endpoints = { | |
list: () => `/list`, | |
create: () => `/create`, | |
update: ({ id }: { id: string }) => `/update?id=${id}`, | |
delete: ({ id }: { id: string }) => `/delete?id=${id}`, | |
detail: ({ id }: { id: string }) => `/detail?id=${id}` | |
}; |
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 { ITodo } from '@/type'; | |
import { api } from './api'; | |
import { endpoints } from './endpoints'; | |
export const createTodo = async ({ todo }: { todo: string }) => { | |
try { | |
const { data } = await api.post<ITodo>(endpoints.create(), { title: todo }); | |
return data; | |
} catch (error) { |
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 { createAxios } from '../../axios'; | |
export const api = createAxios({ baseURL: '/api/todos' }); |
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 axios, { AxiosInstance } from 'axios'; | |
import { toast } from 'react-toastify'; | |
interface ICreateAxios { | |
baseURL: string; | |
} | |
export function createAxios({ baseURL = '/' }: ICreateAxios): AxiosInstance { | |
const headers = { | |
'Content-Type': 'application/json' | |
}; |
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 'react-toastify/dist/ReactToastify.css'; | |
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | |
import { ToastContainer } from 'react-toastify'; | |
import type { AppProps } from 'next/app'; | |
const queryClient = new QueryClient({ | |
defaultOptions: { | |
queries: { |
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
npm info it worked if it ends with ok | |
npm verb cli [ | |
npm verb cli 'C:\\Program Files\\nodejs\\node.exe', | |
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', | |
npm verb cli 'prefix', | |
npm verb cli '-g' | |
npm verb cli ] | |
npm info using npm@6.14.4 | |
npm info using node@v14.0.0 | |
npm verb exit [ 0, true ] |
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
npm info it worked if it ends with ok | |
npm verb cli [ | |
npm verb cli 'C:\\Program Files\\nodejs\\node.exe', | |
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', | |
npm verb cli 'prefix', | |
npm verb cli '-g' | |
npm verb cli ] | |
npm info using npm@6.14.4 | |
npm info using node@v14.0.0 | |
npm verb exit [ 0, true ] |
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
npm info it worked if it ends with ok | |
npm verb cli [ | |
npm verb cli 'C:\\Program Files\\nodejs\\node.exe', | |
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', | |
npm verb cli 'prefix', | |
npm verb cli '-g' | |
npm verb cli ] | |
npm info using npm@6.14.4 | |
npm info using node@v14.0.0 | |
npm verb exit [ 0, true ] |