Closed Johnrobmiller closed 1 year ago
What behavior would you want instead?
I suppose to make sure we are on this same page, is this the intended way to pass the user's input and a summary to my endpoint?
Ah, I see what you mean. I'll add support for data and GET
or POST
mode, will just default to GET
.
I'll use URLSearchParams()
behind the scenes but yes this would be how you do it for now, just put it in the query params manually and read it from req
in your API route. I've got you on a better pattern shortly though.
@Johnrobmiller New major should work for this, can you let me know if the docs are clear enough and whether you find it easy enough to use?
See the demo at https://nextjs-openai.vercel.app/ which now uses POST data. It is also POST by default now.
Just use const data = await req.json()
in the Edge function, where you sent data
as <StreamingTextURL url={url} data={data}>
or equivalent buffer options for the hook via useTextBuffer({ url, data })
.
I know it's possible to put a query in the url, and maybe this is more RESTful, but it's also a more complex solution, which, in my opinon, makes it not as good as simply being able to add a POST body when making the api call.