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

custom route for delete with data. Is it possible? #39

Open
plandem opened this issue Mar 23, 2018 · 9 comments
Open

custom route for delete with data. Is it possible? #39

plandem opened this issue Mar 23, 2018 · 9 comments

Comments

@plandem
Copy link

plandem commented Mar 23, 2018

Hi

I tried, but it appends data into the URL. In my case it's not a valid way to call 'delete' api endpoint. How to achieve this - call custom route for delete with data?

@drewjbartlett
Copy link
Collaborator

Can you provide a code sample please? @plandem

@plandem
Copy link
Author

plandem commented Mar 28, 2018

What are you talking about? Only GET and HEAD can't have body, afaik (need to check RFC to be sure, but fetch works in that way). So there is no reason to restrict the DELETE to have a body.

@drewjbartlett
Copy link
Collaborator

Sorry, not sure I'm following your question. I thought you were asking how to append data but now you're saying it's not valid? Please elaborate a little more if you could so I can understand.

@plandem
Copy link
Author

plandem commented Mar 29, 2018

I asked how to use DELETE and send data same time? By the RFC standard DELETE can have non empty body.

@plandem
Copy link
Author

plandem commented Mar 29, 2018

const customRoutes = [
    {
        name: 'user-delete',
        url: '/users',
        type: 'delete'
    },
];

const rapid = new Rapid({ customRoutes });

//this one is not working right now, library sends empty body in case of 'DELETE'
rapid.route('user-delete', null, { idList: [1,2,3,4,5] });

@drewjbartlett
Copy link
Collaborator

Interesting. This may be a solution for the moment but I think I may want to add better support in v2 which is currently underway.

model.withParam('idList', [1, 2, 3, 4, 5]).route('user-delete') which will generate: api/users?idList%5B0%5D=1&idList%5B1%5D=2&idList%5B2%5D=3&idList%5B3%5D=4&idList%5B4%5D=5

@plandem
Copy link
Author

plandem commented Mar 29, 2018

Sorry, in my case it will not help, because server expects idList from body :(

@plandem
Copy link
Author

plandem commented Mar 29, 2018

Do you mean library can't do it? Because by RFC standard anything except HEAD and GET can have a body.
E.g.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE

That's why I asked. Had not tried axios directly, maybe there is a problem from the axios side.

@drewjbartlett
Copy link
Collaborator

@plandem I will have to look into this more at another time. Sorry! Just swamped at the moment!

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