Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request headers in DELETE method #131

Open
dioxine opened this issue Dec 3, 2020 · 1 comment
Open

Request headers in DELETE method #131

dioxine opened this issue Dec 3, 2020 · 1 comment

Comments

@dioxine
Copy link

dioxine commented Dec 3, 2020

Hello. Thanx for so nice and powerfull product! A little nuance i'd like to observe. It wasn't really clear for me to get it work, until i look at code, cause the order definitely has meaning.
This one doesn't work:

const del = bent(
      "https://xxx.com/",
      "DELETE",
      "json",
      200,
      {
        authorization: `Bearer secretblablabla`,
      },
    );
const response = await del("sessions/sign_out");

but this one - works:

const del = bent(
      200,
      "DELETE",
      "json",
      {
        authorization: `Bearer secretblablabla`,
      },
      "https://xxx.com/"
    );
const response = await del("sessions/sign_out");

and headers object doesn't work in request if it looks like:

{  headers: 
    {  authorization: `Bearer secretblablabla`,  },
}

but it goes ok without "headers" wrapper!

maybe someone will find that info usefull

@hst-m
Copy link

hst-m commented Dec 4, 2020

The order doesn't matter as you can see here https://github.com/mikeal/bent/blob/master/src/core.js#L11 so you must be doing something wrong

And why are you trying to do headers like that? Did you read the docs at all?

Ok looks like you read this part async request(url[, body=null, headers={}]) and thought it meant to put { headers: { } } but it is just saying headers is supposed to be an object, not wrapped in another object like you have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants