-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reviews): implement actual pagination functionality (#161)
- Loading branch information
Showing
6 changed files
with
274 additions
and
71 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import config from '@/config'; | ||
import axios from 'axios'; | ||
|
||
export default function fetchReviews(id, page, limit) { | ||
// eslint-disable-next-line no-async-promise-executor | ||
return new Promise(async (resolve, reject) => { | ||
const baseURL = `${config.api.url}/bots/${id}/reviews`; | ||
const url = new URL(baseURL); | ||
if (page) url.searchParams.append('page', page); | ||
if (limit) url.searchParams.append('limit', limit); | ||
|
||
try { | ||
const response = await axios.get(url, { withCredentials: true }); | ||
resolve(response.data); | ||
} catch (error) { | ||
reject(error instanceof axios.AxiosError ? (error.response?.data?.error || error.message) : error.message); | ||
} | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import config from '@/config'; | ||
import axios from 'axios'; | ||
|
||
export default function fetchReviews(id, page, limit) { | ||
// eslint-disable-next-line no-async-promise-executor | ||
return new Promise(async (resolve, reject) => { | ||
const baseURL = `${config.api.url}/servers/${id}/reviews`; | ||
const url = new URL(baseURL); | ||
if (page) url.searchParams.append('page', page); | ||
if (limit) url.searchParams.append('limit', limit); | ||
|
||
try { | ||
const response = await axios.get(url, { withCredentials: true }); | ||
resolve(response.data); | ||
} catch (error) { | ||
reject(error instanceof axios.AxiosError ? (error.response?.data?.error || error.message) : error.message); | ||
} | ||
}); | ||
} |
Oops, something went wrong.