diff --git a/src/electron/fetchApi.ts b/src/electron/fetchApi.ts index f669ae78..73f5433e 100644 --- a/src/electron/fetchApi.ts +++ b/src/electron/fetchApi.ts @@ -41,7 +41,11 @@ const fetchApi: { [key: string]: (key: string, val: unknown) => unknown } = { agent, }); if (result.ok) { - return { status: result.status, data: await result.json() }; + const data = result.headers.get('content-type').includes('application/json') + ? await result.json() + : (await result.text())?.split('\n')?.filter(Boolean); + + return { status: result.status, data }; } throw new CustomError(result.status, await result.text()); } catch (e) { diff --git a/src/store/connectionStore.ts b/src/store/connectionStore.ts index e3b1236b..a0cd90be 100644 --- a/src/store/connectionStore.ts +++ b/src/store/connectionStore.ts @@ -147,13 +147,12 @@ export const useConnectionStore = defineStore('connectionStore', { const newIndex = this.established.indices.find( ({ index: indexName }: ConnectionIndex) => indexName === index, ); - if (!newIndex) { - return; + if (newIndex) { + if (!newIndex.mapping) { + newIndex.mapping = await client.get(`/${index}/_mapping`, 'format=json'); + } + this.established = { ...this.established, activeIndex: newIndex }; } - if (!newIndex.mapping) { - newIndex.mapping = await client.get(`/${index}/_mapping`, 'format=json'); - } - this.established = { ...this.established, activeIndex: newIndex }; } } catch (err) { console.error('failed to refresh index mapping', err);