Issue #1885Opened March 12, 2019by ghost1 reactions

change storage manager request method to PATCH

Question

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

Answers (3)

tranle13September 10, 20201 reactions

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?

rukavinaMarch 20, 20190 reactions

:+1: 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.

artfMarch 24, 20190 reactions

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

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.