Podpora notifikací - uprava erroru

This commit is contained in:
Reallag 2023-06-10 18:53:08 +02:00
parent ae5d53bcf3
commit 08febd4af2
2 changed files with 7 additions and 11 deletions

View File

@ -166,3 +166,5 @@ const HOST = process.env.HOST || '0.0.0.0';
server.listen(PORT, () => {
console.log(`Server listening on ${HOST}, port ${PORT}`);
});
console.log(process.env.API_KEY)

View File

@ -4,7 +4,7 @@ import {NotififaceInput, NotifikaceData, UdalostEnum} from "./types";
const url = 'your_URL_here'; // Place your URL here
export const gotifyCall = async (data: NotififaceInput): Promise<AxiosResponse> => {
export const gotifyCall = async (data: NotififaceInput): Promise<void> => {
const options = {
headers: {"Content-Type": "application/json"},
@ -21,7 +21,7 @@ export const gotifyCall = async (data: NotififaceInput): Promise<AxiosResponse>
success: true,
message: "Notifikace doručena",
};
return response;
console.log(response)
} catch (error: unknown) {
if (axios.isAxiosError(error)) {
const axiosError = error as AxiosError;
@ -30,17 +30,11 @@ export const gotifyCall = async (data: NotififaceInput): Promise<AxiosResponse>
success: false,
message: "fail",
};
return axiosError.response;
console.log(axiosError.response);
}
}
// Handle unknown error without a response
return {
status: 500,
statusText: 'Unknown error',
headers: {}, // empty headers
data: {success: false, message: "fail"},
config: {}, // empty config
};
console.log("unkown error")
}
};