Unable to use fetch with POST, "Cannot convert object to primitive value"
Answered
Asian black bear posted this in #help-forum
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?
2 Replies
@Asian black bear 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?
try changing
...headerList to ...Object.fromEntries(headerList)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