mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 19:54:13 +00:00
(UI) pas form values to API
This commit is contained in:
parent
3c9458cd17
commit
6e9843baee
1 changed files with 10 additions and 4 deletions
|
@ -3,11 +3,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const keyCreateCall = async (
|
export const keyCreateCall = async (
|
||||||
proxyBaseUrl: String,
|
proxyBaseUrl: string,
|
||||||
accessToken: String,
|
accessToken: string,
|
||||||
userID: String
|
userID: string,
|
||||||
|
formValues: Record<string, any> // Assuming formValues is an object
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
|
console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API call
|
||||||
const response = await fetch(`${proxyBaseUrl}/key/generate`, {
|
const response = await fetch(`${proxyBaseUrl}/key/generate`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -16,15 +18,18 @@ export const keyCreateCall = async (
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
user_id: userID,
|
user_id: userID,
|
||||||
|
...formValues, // Include formValues in the request body
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json();
|
||||||
|
console.error("Error response from the server:", errorData);
|
||||||
throw new Error("Network response was not ok");
|
throw new Error("Network response was not ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
console.log("API Response:", data);
|
||||||
return data;
|
return data;
|
||||||
// Handle success - you might want to update some state or UI based on the created key
|
// Handle success - you might want to update some state or UI based on the created key
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -33,6 +38,7 @@ export const keyCreateCall = async (
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const keyDeleteCall = async (
|
export const keyDeleteCall = async (
|
||||||
proxyBaseUrl: String,
|
proxyBaseUrl: String,
|
||||||
accessToken: String,
|
accessToken: String,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue