Podpora notifikací - uprava erroru
This commit is contained in:
parent
ae5d53bcf3
commit
08febd4af2
@ -166,3 +166,5 @@ const HOST = process.env.HOST || '0.0.0.0';
|
|||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
console.log(`Server listening on ${HOST}, port ${PORT}`);
|
console.log(`Server listening on ${HOST}, port ${PORT}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(process.env.API_KEY)
|
@ -4,7 +4,7 @@ import {NotififaceInput, NotifikaceData, UdalostEnum} from "./types";
|
|||||||
|
|
||||||
const url = 'your_URL_here'; // Place your URL here
|
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 = {
|
const options = {
|
||||||
headers: {"Content-Type": "application/json"},
|
headers: {"Content-Type": "application/json"},
|
||||||
@ -21,7 +21,7 @@ export const gotifyCall = async (data: NotififaceInput): Promise<AxiosResponse>
|
|||||||
success: true,
|
success: true,
|
||||||
message: "Notifikace doručena",
|
message: "Notifikace doručena",
|
||||||
};
|
};
|
||||||
return response;
|
console.log(response)
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
const axiosError = error as AxiosError;
|
const axiosError = error as AxiosError;
|
||||||
@ -30,17 +30,11 @@ export const gotifyCall = async (data: NotififaceInput): Promise<AxiosResponse>
|
|||||||
success: false,
|
success: false,
|
||||||
message: "fail",
|
message: "fail",
|
||||||
};
|
};
|
||||||
return axiosError.response;
|
console.log(axiosError.response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle unknown error without a response
|
// Handle unknown error without a response
|
||||||
return {
|
console.log("unkown error")
|
||||||
status: 500,
|
|
||||||
statusText: 'Unknown error',
|
|
||||||
headers: {}, // empty headers
|
|
||||||
data: {success: false, message: "fail"},
|
|
||||||
config: {}, // empty config
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user