2025-01-26 19:20:36 +03:00
|
|
|
import { FetchBaseQueryError } from "@reduxjs/toolkit/query";
|
|
|
|
|
|
|
|
import { BaseResponse } from "../../models/api";
|
|
|
|
|
|
|
|
export const extractBodyFromResponse = <Body>(response: BaseResponse<Body>) => {
|
|
|
|
if (response.success) {
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const extractErrorMessageFromResponse = ({ data }: FetchBaseQueryError) => {
|
|
|
|
if (typeof data === 'object' && 'message' in data && typeof data.message === 'string') {
|
|
|
|
return data.message;
|
|
|
|
}
|
2025-02-02 11:59:27 +03:00
|
|
|
};
|