question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"TypeError: Cannot read property 'loadFromJSON' of undefined"

See original GitHub issue

Hi All, I am saving the drawn item to local storage and rendering the canvas of the html page when the page is reloaded. `
saveDrawing () { var serializedData = window.drawer.api.getCanvasAsJSON(); var res = JSON.stringify(serializedData) if (res) localStorage.setItem(‘canvas’, res) },

 loadDrawing () {
    var parseData = JSON.parse(localStorage.getItem('canvas'))
   window.drawer.api.loadCanvasFromData(parseData)
 }

` I get the exceptions saying TypeError: Cannot read property ‘loadFromJSON’ of undefined at DrawerConstructor.Drawer.loadCanvas (drawerJs.standalone.js:29762) at DrawerApi.loadCanvasFromData (drawerJs.standalone.js:27517) at VueComponent.loadDrawing (DrawTool.vue?fd05:304) at VueComponent.mounted (DrawTool.vue?fd05:248) at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854) at callHook (vue.runtime.esm.js?2b0e:4213) at Object.insert (vue.runtime.esm.js?2b0e:3139) at invokeInsertHook (vue.runtime.esm.js?2b0e:6340) at Vue.patch [as patch] (vue.runtime.esm.js?2b0e:6559) at Vue._update (vue.runtime.esm.js?2b0e:3939)

How to fix this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
extremeCrazyCodercommented, Oct 15, 2019

I am getting the same error when loading the data that way it seems that you have to start the editing before you can load the data that way…

it works if I write the loading that way:

    function loadDrawing () {
        var parseData = JSON.parse(localStorage.getItem('canvas'))
        window.drawer.api.startEditing();
        window.drawer.api.loadCanvasFromData(parseData)
        window.drawer.api.stopEditing();
    }
0reactions
edfrommathclasscommented, Apr 27, 2021

@extremeCrazyCoder, thanks for being passionate with this. It is not crashing always but sometimes the background image takes time to load which causes this issue. I will do some work around on contentConfig.

Hi Naveen, did you ever figure this out?? I’m encountering the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'fromObject' of undefined - Stack Overflow
I stringify my canvas and load it from another canvas using loadFromJSON and I got this error "Cannot read property 'fromObject' of ...
Read more >
Uncaught TypeError: Cannot read property 'async' of undefined
I've created a custom class with a custom property called "id". The code is like this: <canvas id="main-canvas" width="300" height="300" style="border:1px ...
Read more >
Uncaught [TypeError: Cannot read property 'clearRect' of null ...
Uncaught [TypeError: Cannot read property 'clearRect' of null] with fabric js canvas.loadFromJSON ... I am using fabric js and want to use editly ......
Read more >
javascript - Fabric.js subclassing fabric.Group - Error: "Cannot read ...
The error "Cannot read property 'async' of undefined" is raised because no ... you have to declare the fromObject method - it's needed...
Read more >
Load From JSON Object Error Uncaught TypeError - DataTables
Error message: Uncaught TypeError: Cannot set property 'nTf' of undefined. Please help to see where i go wrong.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found