How to update the editor data dynamically? (axios)
See original GitHub issueHi,
I integrated the vue-editor-js in my vue project and it works fine. Saving the data into my database works.
Unfortunately I can’t find a way to dynamically update the <editor> component data.
How to update the editor data from my data retreived from the database?
<template>
<editor :init-data="articleBlocks" />
</template>
<script>
export default {
data() {
return {
articleBlocks: {}
}
},
methods: {
onListEdit(listId) {
axios.get('/api/lists/' + listId)
.then(response => {
let item = response.data;
this.articleBlocks = JSON.parse(item.articleBlocks);
})
;
}
}
}
</script>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
ReactJS - Dynamically updating HTML when API returns ...
Try setMatchInfo(response.data) instead. Share.
Read more >Making Dynamic Axios API Queries in React - DevCamp
So I'm gonna say method and then the next one is just going to be URL. And that's gonna be this.state.apiUrl and then...
Read more >Fetch API data with Axios and display it in a React app with ...
This article will go over how to fetch data with Axios in React, save it to state, and then display it in a...
Read more >Getting Started with Axios | Bits and Pieces
With GET, we can read data. With POST, we can write/overwrite data to our resource. With PATCH, we can update data within our...
Read more >Client-side routing for dynamic pages | Frontend Development
You need a data source extension to fetch the list of movies from the SWAPI and a custom Frontend component to render the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
I tried this too. Unfortunately I can’t get it to work, and I don’t know why. That’s really a pity, because saving works just fine.
Looks like :init-data requires an object (I just pass an empty object by now), but the “blocks” part of the returned data is an array of block objects. This isn’t compatible. It’s not defined what " :init-data" is, and how to initialize / update it correctly. I’ve done this with try and error.
Maybe it’s possible for you to create an example, how the loading / saving of data works.
I think we would have to add a load/render function to the editor: https://editorjs.io/blocks#render
Hm wait that is only a blocks api. …
Probably the editor has to be reinitialized.