From aef603ed8ce45feba9e19ffffdfd412cc7c85bea Mon Sep 17 00:00:00 2001 From: lurong Date: Sun, 25 Feb 2018 22:50:51 +0800 Subject: [PATCH] rebase and prefer const in node list --- browser/main/NoteList/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 56101b63..3db88dd1 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -681,13 +681,14 @@ class NoteList extends React.Component { const selectedNotes = findNotesByKeys(notes, selectedNoteKeys) const firstNote = selectedNotes[0] const config = ConfigManager.get() - let {address, token, authMethod, username, password} = config.blog + const {address, token, authMethod, username, password} = config.blog + let authToken = '' if (authMethod === 'USER') { - token = `Basic ${window.btoa(`${username}:${password}`)}` + authToken = `Basic ${window.btoa(`${username}:${password}`)}` } else { - token = `Bearer ${token}` + authToken = `Bearer ${token}` } - let contentToRender = firstNote.content.replace(`# ${firstNote.title}`, '') + const contentToRender = firstNote.content.replace(`# ${firstNote.title}`, '') var data = { title: firstNote.title, content: markdown.render(contentToRender), @@ -708,7 +709,7 @@ class NoteList extends React.Component { method: method, body: JSON.stringify(data), headers: { - 'Authorization': token, + 'Authorization': authToken, 'Content-Type': 'application/json' } }).then(res => res.json())