Skip to content

Commit

Permalink
Merge pull request #51 from keriati/main
Browse files Browse the repository at this point in the history
handle responses.json when it is an array
  • Loading branch information
longy2k authored Feb 21, 2024
2 parents 4e5cf1c + ac3a861 commit cf06084
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/FetchModelList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ export async function fetchRESTAPIURLModels(plugin: BMOGPT) {
});

// Check if the response is valid
if (response.json && response.json.data) {
const models = response.json.data.map((model: { id: number; }) => model.id);
if (response.json && (response.json.data || Array.isArray(response.json))) {
let models;
if (Array.isArray(response.json)) {
models = response.json.map((model: { id: number; }) => model.id);
} else {
models = response.json.data.map((model: { id: number; }) => model.id);
}

plugin.settings.RESTAPIURLConnection.RESTAPIURLModels = models;
return models;
}
Expand Down

0 comments on commit cf06084

Please sign in to comment.