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

change storage manager request method to PATCH #1885

Closed
ghost opened this issue Mar 12, 2019 · 3 comments
Closed

change storage manager request method to PATCH #1885

ghost opened this issue Mar 12, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 12, 2019

Hey @artf does the storage manager support changing the request method from post to patch?
I did not see that anywehre in the docs.

@rukavina
Copy link

👍
As per source code it's not supported but it should for sure. Semantically POST creates resources, while storage is actually updating it. So PUT or PATCH are more valid IMHO.

Anyway, the best is to provide ability to let you decide which method should be used while sending "update" requests.

@artf
Copy link
Member

artf commented Mar 24, 2019

Anyway, the best is to provide ability to let you decide which method should be used while sending "update" requests.

I agree...

Probably I'll add this option (storageManager module) in the next release:

storageManager: {
	...
	// Pass custom options to fetch API (remote storage)
  	// You can pass a simple object: { someOption: 'someValue' }
 	// or a function wich returns and object to add:
	// currentOpts => {
  	//  return currentOpts.method === 'post' ?  { method: 'patch' } : {};
  	// }
  	fetchOptions: '',
},

So, in this case, you'll be able to distinguish the type of the call (store/load) by currentOpts.method === 'post' and decide what option to add. Not super elegant but at least will work for most of the cases, will not gonna break the current implementation and works also for other fetch options

@artf artf closed this as completed in 5d26790 Mar 24, 2019
@tranle13
Copy link

Hi @artf ! I just started using GrapesJS (awesome plug-in btw, thank you so much!) and I'm wondering whether this has been added or not?

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

3 participants