Next.js Discord

Discord Forum

Unable to use fetch with POST, "Cannot convert object to primitive value"

Answered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
Simply trying to do a fetch request using POST method triggers the error "Cannot convert object to primitive value" in runtime. Code is inside a server action, haven't tested in client components. Does the fetch API extended with next features is unable to do POST requests?
Answered by Ray
try changing ...headerList to ...Object.fromEntries(headerList)
View full answer

2 Replies

Answer
@Ray try changing `...headerList` to `...Object.fromEntries(headerList)`
Asian black bearOP
thanks very much, didn't notice that headerList has methods. Thats a good reason for me to pay more attention to docs. Thanks