rm requestGet
This commit is contained in:
1 parent
ecb81f756a
commit
3794a926b5
1 file changed
-11
@@ -1,4 +1,3 @@
|
|||||||
import axios from 'axios'
|
|
||||||
import { NextPageContext } from 'next'
|
import { NextPageContext } from 'next'
|
||||||
|
|
||||||
export interface IResponseItems<T> {
|
export interface IResponseItems<T> {
|
||||||
@@ -7,16 +6,6 @@ export interface IResponseItems<T> {
|
|||||||
prevPage: number
|
prevPage: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function requestGet<T>(url: string, defaultResponse: T): Promise<T> {
|
|
||||||
try {
|
|
||||||
const res = await axios.get<T>(url)
|
|
||||||
|
|
||||||
return res.data
|
|
||||||
} catch (e) {
|
|
||||||
return defaultResponse
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This wrapper prevents fetching api request in static export mode and production environment
|
* This wrapper prevents fetching api request in static export mode and production environment
|
||||||
* because nextjs call getInitialProps on the client side
|
* because nextjs call getInitialProps on the client side
|
||||||
|
|||||||
Reference in new issue
Block a user