I’m new to nylon just started using it today, I was try to integrate it to my old next js app router project follow the setup of using nodejs i almost get it but seeing this error.
type: 'provider_error',
requestId: 'a01984eb-21d4-4fe2-ae55-5b03a37130a1',
providerError: {
error: { code: 400, message: 'The specified time range is empty.' }
},
statusCode: 400
}
This my code for create-event:
`
export async function POST(request: Request) {
const { accessToken, startTime, endTime, title, description, email } =
await request.json();
// if (!accessToken || !startTime || !endTime || !title) {
// return NextResponse.json(
// { error: "Missing required fields" },
// { status: 400 },
// );
// }
try {
const event = await ns.events.create({
identifier: process.env.NYLAS_GRANT_ID as string,
requestBody: {
calendarId: "primary",
title,
description,
when: { startTime, endTime },
participants: [{
email: email,
status: "noreply"
}],
},
queryParams: {
calendarId: "primary"
}
});
return NextResponse.json({ success: true, event });
} catch (error) {
console.error("Error creating event:", error);
return NextResponse.json(
{ error: "Failed to create event" },
{ status: 500 },
);
}
}
`
how am using it
const handleBooking = async () => { if (currentUser) { try { const token = await currentUser.getIdToken(); const response = await axios.post('/api/create-event', { title, description, email, startTime: new Date(startTime).getTime() / 1000, endTime: new Date(endTime).getTime() / 1000, }, { headers: { token }, }); console.log('Event created:', response.data); } catch (error) { console.error('Error creating event:', error); } } };
am using firebase as auth. that’s what am using from start of the project.