API change name of note #2057
-
I want to use a script to change the name of a note |
Beta Was this translation helpful? Give feedback.
Answered by
abitofevrything
Jul 21, 2021
Replies: 1 comment 3 replies
-
You can use this: async function setNoteTitle(noteId, title) {
return await api.runOnBackend((noteId, title) => {
const becca = require('../becca/becca');
const noteService = require('./notes');
const note = becca.getNote(noteId);
if (!note) {
return [404, `Note ${noteId} has not been found`];
}
if (!note.isContentAvailable()) {
return [400, `Note ${noteId} is not available for change`];
}
const noteTitleChanged = note.title !== title;
note.title = title;
note.save();
if (noteTitleChanged) {
noteService.triggerNoteTitleChanged(note);
}
}, [noteId, title]);
} This is (nearly) the exact same code used normally for renaming notes, which you can find here. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Sebiann
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use this: