Fixing failed api requests.

This commit is contained in:
Roland 2022-05-01 21:12:39 -06:00
parent 3673092847
commit e5b2135cb2
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 4 additions and 6 deletions

View file

@ -111,7 +111,7 @@ export async function deleteChannel(id) {
export async function getChannels() {
let response = await apiGet(`${VIDEOS_API}/channels`);
if (response.stack === 200) {
if (response.status === 200) {
return (await response.json())['channels'];
} else {
toast({
@ -185,7 +185,7 @@ export async function getDirectories(search_str) {
export async function getSettings() {
let response = await apiGet(`${API_URI}/settings`);
if (response === 200) {
if (response.status === 200) {
return await response.json();
} else {
toast({

View file

@ -306,15 +306,13 @@ class Videos extends React.Component {
// Pass any enabled filters to the search.
let filtersArr = this.enabledFilters();
let videos = [];
let total = 0;
try {
let [videos, total] = await searchVideos(offset, limit, channel_id, queryStr, searchOrder, filtersArr);
let totalPages = Math.round(total / this.state.limit) || 1;
this.setState({videos, totalPages});
} catch (e) {
console.error(e);
}
let totalPages = Math.round(total / this.state.limit) || 1;
this.setState({videos, totalPages});
}
changePage = async (activePage) => {