add limit query parameter for FeedApi, check other APIs for missing options
This commit is contained in:
+5
-1
@@ -8,6 +8,7 @@ export const URL = `${process.env.NEXT_PUBLIC_API_URL}/events/`;
|
||||
export interface Options {
|
||||
onlyNonPast?: boolean;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
auth?: boolean;
|
||||
}
|
||||
|
||||
@@ -26,11 +27,14 @@ class EventApi {
|
||||
}
|
||||
|
||||
static async getEvents(options: Options = {}): Promise<Event[]> {
|
||||
const { onlyNonPast, limit, auth } = options;
|
||||
const {
|
||||
onlyNonPast, limit, offset, auth,
|
||||
} = options;
|
||||
try {
|
||||
const params = {
|
||||
since: onlyNonPast ? (new Date()).toISOString() : undefined,
|
||||
limit,
|
||||
offset,
|
||||
};
|
||||
const headers = auth ? { Authorization: getAuthHeader() } : null;
|
||||
const resp = await axios.get(`${URL}`, {
|
||||
|
||||
+10
-2
@@ -6,15 +6,23 @@ import { getAuthHeader } from "@utils/auth";
|
||||
export const URL = `${process.env.NEXT_PUBLIC_API_URL}/feed/`;
|
||||
|
||||
export interface Options {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
auth?: boolean;
|
||||
}
|
||||
|
||||
class FeedApi {
|
||||
static async getFeed(options: Options = {}): Promise<Post[]> {
|
||||
const { auth } = options;
|
||||
const {
|
||||
limit, offset, auth,
|
||||
} = options;
|
||||
const params = {
|
||||
limit,
|
||||
offset,
|
||||
};
|
||||
const headers = auth ? { Authorization: getAuthHeader() } : null;
|
||||
try {
|
||||
const resp = await axios.get(URL, { headers });
|
||||
const resp = await axios.get(URL, { params, headers });
|
||||
return resp.data.results;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
+5
-1
@@ -8,16 +8,20 @@ export const URL = `${process.env.NEXT_PUBLIC_API_URL}/jobads/`;
|
||||
export interface Options {
|
||||
onlyNonPast?: boolean;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
auth?: boolean;
|
||||
}
|
||||
|
||||
class JobAdApi {
|
||||
static async getJobAds(options: Options = {}): Promise<JobAd[]> {
|
||||
const { onlyNonPast, limit, auth } = options;
|
||||
const {
|
||||
onlyNonPast, limit, offset, auth,
|
||||
} = options;
|
||||
try {
|
||||
const params = {
|
||||
since: onlyNonPast ? (new Date()).toISOString() : undefined,
|
||||
limit,
|
||||
offset,
|
||||
};
|
||||
const headers = auth ? { Authorization: getAuthHeader() } : null;
|
||||
const resp = await axios.get(`${URL}`, {
|
||||
|
||||
@@ -6,10 +6,12 @@ import { getAuthHeader } from "@utils/auth";
|
||||
export const URL = `${process.env.NEXT_PUBLIC_API_URL}/signup/`;
|
||||
export const FORM_URL = `${process.env.NEXT_PUBLIC_API_URL}/signupForm/`;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface Options {
|
||||
onlyNonPast?: boolean;
|
||||
limit?: number;
|
||||
auth?: boolean;
|
||||
// onlyNonPast?: boolean;
|
||||
// limit?: number;
|
||||
// offset?: number;
|
||||
// auth?: boolean;
|
||||
}
|
||||
|
||||
class SignupApi {
|
||||
|
||||
+4
-3
@@ -4,10 +4,11 @@ import Tag from "@models/Tag";
|
||||
|
||||
export const URL = `${process.env.NEXT_PUBLIC_API_URL}/tags/`;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface Options {
|
||||
onlyNonPast?: boolean;
|
||||
limit?: number;
|
||||
auth?: boolean;
|
||||
// limit?: number;
|
||||
// offset?: number;
|
||||
// auth?: boolean;
|
||||
}
|
||||
|
||||
class TagApi {
|
||||
|
||||
Reference in New Issue
Block a user