mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-08-01 18:07:45 -04:00
Generic params type to get a record by id from api
This commit is contained in:
@@ -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 <T = ApiDefaultResult>(
|
||||
}
|
||||
};
|
||||
|
||||
interface ProjectPostsParams extends ApiParams {
|
||||
id: number;
|
||||
}
|
||||
|
||||
const fetchProjectPosts = async <T = ApiDefaultResult>(
|
||||
params: ProjectPostsParams,
|
||||
params: ApiGetByIdParams,
|
||||
opts: ApiOpts = {},
|
||||
): Promise<ApiResponse<T> | null | ErrorWithResponse | INatApiError> => {
|
||||
try {
|
||||
@@ -41,12 +37,8 @@ const fetchProjectPosts = async <T = ApiDefaultResult>(
|
||||
}
|
||||
};
|
||||
|
||||
interface UserPostsParams extends ApiParams {
|
||||
id: number;
|
||||
}
|
||||
|
||||
const fetchUserPosts = async <T = ApiDefaultResult>(
|
||||
params: UserPostsParams,
|
||||
params: ApiGetByIdParams,
|
||||
opts: ApiOpts = {},
|
||||
): Promise<ApiResponse<T> | null | ErrorWithResponse | INatApiError> => {
|
||||
try {
|
||||
|
||||
4
src/api/types.d.ts
vendored
4
src/api/types.d.ts
vendored
@@ -14,6 +14,10 @@ export interface ApiParams {
|
||||
ttl?: number;
|
||||
}
|
||||
|
||||
export interface ApiGetByIdParams extends ApiParams {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface ApiPlace {
|
||||
id?: number;
|
||||
name?: string;
|
||||
|
||||
@@ -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 <T = ApiDefaultResult>(
|
||||
params: UsersProjectsParams,
|
||||
params: ApiGetByIdParams,
|
||||
opts: ApiOpts = {},
|
||||
): Promise<ApiResponse<T> | null | ErrorWithResponse | INatApiError> => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user