I'm fetching markdown from an API and I want to use it in my vuejs app.
I want to have access to the markdown and the converted data.
async getNotes() {
var regxHighlights = /id:\b([0-9]+)\b/g;
var regxNotes = /id-\b([0-9]+)\b/g;
fetch(`/books/${this.id}/notes`).then(res => res.json()).then(res => {
var data = res.map(n => {
n.note = converter.makeHtml(n.note)
n.note = n.note.replace(regxHighlights, `<b class="ref noteRef" style="user-select: none;" data="id$1" >id:$1</b>`);
n.note = n.note.replace(regxNotes, `<b class="ref noteRef" style="user-select: none;" data="id-$1" >id-$1</b>`);
return n
})
this.notes = data
this.rawNotes = res
})
},
The problem is that res
has been changed! So data
and res
are the same thing. That shouldn't happen right!