Issue #1885💬 AnsweredOpened March 12, 2019by ghost1 reactions

Change storage manager request method to PATCH

快速解答by tranle131

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?

Read full answer below ↓

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, 2020

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, 2019

:+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, 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

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.