mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
Merge pull request #45 from Hestia-Homes/costs-migration
Awaiting fetch in plan trigger api
This commit is contained in:
commit
6b49fb9196
1 changed files with 13 additions and 5 deletions
|
|
@ -50,16 +50,24 @@ export async function POST(request: NextRequest) {
|
|||
console.log("Triggering plan with url: ", url);
|
||||
console.log("Triggering plan with headers: ", headers);
|
||||
|
||||
// For the moment, we don't await any response from the backend, since we haven't split out the trigger
|
||||
void fetch(url, {
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
body: JSON.stringify(validatedBody),
|
||||
}).catch((err) => {
|
||||
console.error("Error triggering FastAPI plan:", err);
|
||||
});
|
||||
|
||||
console.log("Plan triggered successfully");
|
||||
console.log("Plan triggered successfully, status: %", response.statusText);
|
||||
if (!response.ok) {
|
||||
console.error("Error triggering plan:", response.statusText);
|
||||
return new NextResponse(
|
||||
JSON.stringify({ msg: "Error triggering plan" }),
|
||||
{
|
||||
status: 500,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return new NextResponse(JSON.stringify({ msg: "Job started" }), {
|
||||
status: 200,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue