(ui) show error message when creating key

This commit is contained in:
ishaan-jaff 2024-02-01 09:23:00 -08:00
parent 9c4f0877aa
commit 9233058141

View file

@ -1,6 +1,7 @@
/**
* Helper file for calls being made to proxy
*/
import { message } from 'antd';
export const keyCreateCall = async (
proxyBaseUrl: string,
@ -9,7 +10,7 @@ export const keyCreateCall = async (
formValues: Record<string, any> // Assuming formValues is an object
) => {
try {
console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API call
console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API call
const response = await fetch(`${proxyBaseUrl}/key/generate`, {
method: "POST",
headers: {
@ -23,7 +24,8 @@ export const keyCreateCall = async (
});
if (!response.ok) {
const errorData = await response.json();
const errorData = await response.text();
message.error("Failed to create key: " + errorData);
console.error("Error response from the server:", errorData);
throw new Error("Network response was not ok");
}