mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-13 12:01:29 +08:00

* feat: added test alert feature * fix: solved the lint issues Co-authored-by: Palash Gupta <palashgdev@gmail.com>
27 lines
662 B
TypeScript
27 lines
662 B
TypeScript
import axios from 'api';
|
|
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
import { AxiosError } from 'axios';
|
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
|
import { PayloadProps, Props } from 'types/api/alerts/testAlert';
|
|
|
|
const testAlert = async (
|
|
props: Props,
|
|
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
|
|
try {
|
|
const response = await axios.post('/testRule', {
|
|
...props.data,
|
|
});
|
|
|
|
return {
|
|
statusCode: 200,
|
|
error: null,
|
|
message: response.data.status,
|
|
payload: response.data.data,
|
|
};
|
|
} catch (error) {
|
|
return ErrorResponseHandler(error as AxiosError);
|
|
}
|
|
};
|
|
|
|
export default testAlert;
|