mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-18 10:01:31 +08:00
30 lines
829 B
TypeScript
30 lines
829 B
TypeScript
import axios from 'api';
|
|
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
import { AxiosError } from 'axios';
|
|
import convertObjectIntoParams from 'lib/query/convertObjectIntoParams';
|
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
|
import { PayloadProps, Props } from 'types/api/alerts/getTriggered';
|
|
|
|
const getTriggered = async (
|
|
props: Props,
|
|
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
|
|
try {
|
|
const queryParams = convertObjectIntoParams(props);
|
|
|
|
const response = await axios.get(`/alerts?${queryParams}`);
|
|
|
|
const amData = JSON.parse(response.data.data);
|
|
|
|
return {
|
|
statusCode: 200,
|
|
error: null,
|
|
message: response.data.status,
|
|
payload: amData.data,
|
|
};
|
|
} catch (error) {
|
|
return ErrorResponseHandler(error as AxiosError);
|
|
}
|
|
};
|
|
|
|
export default getTriggered;
|