I\'m trying to POST a JSON object using fetch.
From what I can understand, I need to attach a stringified object to the body of the request, e.g.:
If your JSON payload contains arrays and nested objects, I would use URLSearchParams and jQuery's param() method.
URLSearchParams
param()
fetch('/somewhere', { method: 'POST', body: new URLSearchParams($.param(payload)) })
To your server, this will look like a standard HTML being POSTed.
POST