grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[Question] - UrlLoad and UrlSave

Open andyjoneski opened this issue 7 years ago • 1 comments

hi,

Grapesjs is a fantastic bit of software and I've been playing with it for a week or so now. Im struggling a little with the urlLoad.

storageManager: {
    autosave: true,
    setStepsBeforeSave: 2,
    type: 'remote',
    urlStore: '/rest/V1/aware/save/:page_id', 
    urlLoad: '/rest/V1/aware/getJson/:page_id',
    contentTypeJson: true,
    headers: { Authorization: 'Bearer TOKEN' }
}

Im using an end point which is returning json as you can see here:

Screenshot 2019-08-14 at 08 14 15

How I've read the documentation, is this supposed to load the layout into the canvas?

What I'm trying to do, is use the endpoints to save the canvas - and load the canvas etc. But on load nothing happens, I'm left with a blank canvas. Really appreciate if you could point me in the right direction, or a demo etc.

thanks

andyjoneski avatar Aug 14 '19 07:08 andyjoneski

The result of your endpoint is totally wrong. Read carefully this part please: https://grapesjs.com/docs/modules/Storage.html#setup-the-server You should return something like this:

{
  // `gjs-` is the id prefix
  'gjs-components': [{ tagName: 'div', ... }, {...}, ...],
  'gjs-style': [{...}, {...}, ...],
}

Now, you're returning only components:

[{ tagName: 'div', ... }, {...}, ...]

artf avatar Aug 14 '19 14:08 artf