Skip to content

Commit

Permalink
fix(client): fix post comment fail when token empty
Browse files Browse the repository at this point in the history
fix #113
  • Loading branch information
lizheming committed Jan 3, 2021
1 parent 0df35ed commit c8c7792
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/client/src/utils/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export function fetchList({serverURL, path, page, pageSize}) {

export function postComment({serverURL, token, comment}) {
const url = `${serverURL}/comment`;
const headers = {'Content-Type': 'application/json'};
if(token) {
headers.Authorization = `Bearer ${token}`;
}

return fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
headers,
body: JSON.stringify(comment)
}).then(resp => resp.json());
}
Expand Down

0 comments on commit c8c7792

Please sign in to comment.