Issue #597Opened November 30, 2017by DeathStapler2 reactions

storageManager: Loading from remote storage

Question

Hi,

I'm trying to read the HTML and CSS from my database. When I try to load it into the editor, nothing displays. I can store the data just, just cannot load it.

Is this the correct format for the data when you are loading it?

Content-type

application/json

Preview

{gjs-assets: "", gjs-components: "",…}
   gjs-assets : ""
   gjs-components : ""
   gjs-css : "*{box-sizing: border-box;}body{margin:0;}.c1077{padding:10px;}"
   gjs-html : "<div class="c1077">Insert your text here</div>"
   gjs-styles : ""

Response

{"gjs-assets":"","gjs-components":"","gjs-css":"*{box-sizing: border-box;}body{margin:0;}.c1077{padding:10px;}","gjs-html":"<div class=\"c1077\">Insert your text here<\/div>","gjs-styles":""}

Answers (3)

DeathStaplerDecember 6, 20171 reactions

So when I set:

contentTypeJson: true,

resulting in:

storageManager: {
            type: 'remote',
            autoload: true,
            stepsBeforeSave: 1,
            contentTypeJson: true,
            urlStore: "/save-template/2",
            urlLoad: "/load-template/2", 
            params: {},   // For custom values on requests
          },

I can now load from the database. But, now it will not save, because it is sending the data as JSON. How can I send the data as POST variables, but receive it as JSON?

duskhackerDecember 1, 20170 reactions

@DeathStapler This is what mine looks like:

{
    "gjs-css":"*{box-sizing: border-box;}body{margin:0;}.c1050{padding:10px;}", 
    "gjs-html":"<div class="c1050">Hi</div>", 
    "gjs-assets":"[]", 
    "gjs-styles":"[]", 
    "gjs-components":"[]"
  }

The thing that jumps out at me at first is that assets, components and styles should be arrays, you have empty strings.

The Content-Type is correct.

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.