ky: POST request doesn't have body for Tizen 2017

I have options like this one:


const kyOptions = {
    headers: {
        'Authorization': "Bearer <token>",
    },
    json: {
        content_id: "<id>"
        content_type: "<type>"
    },
    method: "post"
};

Then I call ky:

const response = ky(uri, kyOptions);

And I have error as somehow fetch was called without body. If I replace the call with fetch itself, the request will be sent correctly as expected:

const response = await fetch(uri, {
   body: JSON.stringify(kyOptions.json),
   headers: {
      'Content-Type': 'application/json',
      ...kyOptions.headers,
   },
   method: 'POST'
});

Do you know why this can happen?

I use whatwg-fetch and core-js, maybe also something is missed?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Can you please specify which Ky version you are using?

Your code looks fine to me, but here are some things to try for debugging purposes:

  • Use 'POST' in uppercase. Ky normalizes method casing, but I see it’s different between your two examples.
  • Use the body option with Ky, instead of json.
  • Put the body in a Request instance and pass that to Ky as the first argument.