update: showing error in queryresult component

This commit is contained in:
therealrinku 2023-10-10 10:51:45 +05:45
parent d4683ab961
commit 571b4459ac
3 changed files with 8 additions and 2 deletions

View File

@ -11,7 +11,7 @@ import StyledWrapper from './StyledWrapper';
import { useState } from 'react';
import { useMemo } from 'react';
const QueryResult = ({ item, collection, data, width, disableRunEventListener, headers }) => {
const QueryResult = ({ item, collection, data, width, disableRunEventListener, headers, error }) => {
const { storedTheme } = useTheme();
const [tab, setTab] = useState('preview');
const dispatch = useDispatch();
@ -113,7 +113,7 @@ const QueryResult = ({ item, collection, data, width, disableRunEventListener, h
<div className="flex justify-end gap-2 text-xs" role="tablist">
{getTabs()}
</div>
{activeResult}
{error ? <span className="text-red-500">{error}</span> : activeResult}
</StyledWrapper>
);
};

View File

@ -42,6 +42,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
width={rightPaneWidth}
data={response.data}
headers={response.headers}
error={response.error}
/>
);
}

View File

@ -140,6 +140,11 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
})
.then(resolve)
.catch((err) => {
if (err && err.message === "Error invoking remote method 'send-http-request': Error: Request cancelled") {
console.log('>> request cancelled');
return;
}
const errorMessage = err.message ?? 'Something went wrong';
const errorResponse = {