mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-24 02:46:37 +08:00
fix: Cannot read properties of undefined (reading 'map') (close #148)
This commit is contained in:
parent
72962e988f
commit
3800dc219e
@ -322,6 +322,9 @@ const ChannelsTable = () => {
|
|||||||
const res = await API.get(
|
const res = await API.get(
|
||||||
`/api/channel/?p=${startIdx}&page_size=${pageSize}&id_sort=${idSort}`,
|
`/api/channel/?p=${startIdx}&page_size=${pageSize}&id_sort=${idSort}`,
|
||||||
);
|
);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { success, message, data } = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
if (startIdx === 0) {
|
if (startIdx === 0) {
|
||||||
@ -608,6 +611,9 @@ const ChannelsTable = () => {
|
|||||||
let res = await API.get(`/api/group/`);
|
let res = await API.get(`/api/group/`);
|
||||||
// add 'all' option
|
// add 'all' option
|
||||||
// res.data.data.unshift('all');
|
// res.data.data.unshift('all');
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setGroupOptions(
|
setGroupOptions(
|
||||||
res.data.data.map((group) => ({
|
res.data.data.map((group) => ({
|
||||||
label: group,
|
label: group,
|
||||||
|
@ -156,6 +156,9 @@ const SiderBar = () => {
|
|||||||
|
|
||||||
const loadStatus = async () => {
|
const loadStatus = async () => {
|
||||||
const res = await API.get('/api/status');
|
const res = await API.get('/api/status');
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { success, data } = res.data;
|
const { success, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
localStorage.setItem('status', JSON.stringify(data));
|
localStorage.setItem('status', JSON.stringify(data));
|
||||||
|
@ -188,6 +188,9 @@ const EditChannel = (props) => {
|
|||||||
const loadChannel = async () => {
|
const loadChannel = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
let res = await API.get(`/api/channel/${channelId}`);
|
let res = await API.get(`/api/channel/${channelId}`);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { success, message, data } = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
if (data.models === '') {
|
if (data.models === '') {
|
||||||
@ -223,6 +226,9 @@ const EditChannel = (props) => {
|
|||||||
const fetchModels = async () => {
|
const fetchModels = async () => {
|
||||||
try {
|
try {
|
||||||
let res = await API.get(`/api/channel/models`);
|
let res = await API.get(`/api/channel/models`);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let localModelOptions = res.data.data.map((model) => ({
|
let localModelOptions = res.data.data.map((model) => ({
|
||||||
label: model.id,
|
label: model.id,
|
||||||
value: model.id,
|
value: model.id,
|
||||||
@ -244,6 +250,9 @@ const EditChannel = (props) => {
|
|||||||
const fetchGroups = async () => {
|
const fetchGroups = async () => {
|
||||||
try {
|
try {
|
||||||
let res = await API.get(`/api/group/`);
|
let res = await API.get(`/api/group/`);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setGroupOptions(
|
setGroupOptions(
|
||||||
res.data.data.map((group) => ({
|
res.data.data.map((group) => ({
|
||||||
label: group,
|
label: group,
|
||||||
|
Loading…
Reference in New Issue
Block a user