diff --git a/src/api/posts.ts b/src/api/posts.ts index a658e10df..84ecf505a 100644 --- a/src/api/posts.ts +++ b/src/api/posts.ts @@ -1,7 +1,7 @@ import type { ErrorWithResponse, INatApiError } from "api/error"; import handleError from "api/error"; import type { - ApiDefaultResult, ApiOpts, ApiParams, ApiResponse, + ApiDefaultResult, ApiGetByIdParams, ApiOpts, ApiParams, ApiResponse, } from "api/types"; import inatjs from "inaturalistjs"; @@ -21,12 +21,8 @@ const fetchBlogPosts = async ( } }; -interface ProjectPostsParams extends ApiParams { - id: number; -} - const fetchProjectPosts = async ( - params: ProjectPostsParams, + params: ApiGetByIdParams, opts: ApiOpts = {}, ): Promise | null | ErrorWithResponse | INatApiError> => { try { @@ -41,12 +37,8 @@ const fetchProjectPosts = async ( } }; -interface UserPostsParams extends ApiParams { - id: number; -} - const fetchUserPosts = async ( - params: UserPostsParams, + params: ApiGetByIdParams, opts: ApiOpts = {}, ): Promise | null | ErrorWithResponse | INatApiError> => { try { diff --git a/src/api/types.d.ts b/src/api/types.d.ts index 92a932493..d6e4281b3 100644 --- a/src/api/types.d.ts +++ b/src/api/types.d.ts @@ -14,6 +14,10 @@ export interface ApiParams { ttl?: number; } +export interface ApiGetByIdParams extends ApiParams { + id: number; +} + export interface ApiPlace { id?: number; name?: string; diff --git a/src/api/usersTyped.ts b/src/api/usersTyped.ts index 154fab349..fb93b7936 100644 --- a/src/api/usersTyped.ts +++ b/src/api/usersTyped.ts @@ -1,16 +1,12 @@ import type { ErrorWithResponse, INatApiError } from "api/error"; import handleError from "api/error"; import type { - ApiDefaultResult, ApiOpts, ApiParams, ApiResponse, + ApiDefaultResult, ApiGetByIdParams, ApiOpts, ApiResponse, } from "api/types"; import inatjs from "inaturalistjs"; -interface UsersProjectsParams extends ApiParams { - id: number; -} - const fetchUserProjects = async ( - params: UsersProjectsParams, + params: ApiGetByIdParams, opts: ApiOpts = {}, ): Promise | null | ErrorWithResponse | INatApiError> => { try {