Skip to content

Commit

Permalink
fix: workaround for github.activity.markNotificationsAsRead() (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed May 14, 2018
1 parent 935c55c commit c1fc675
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,28 @@ function request (requestOptions) {
// fetch does not allow to set `content-length` header, but we can set body to an empty string
if (['PATCH', 'PUT'].indexOf(requestOptions.method) >= 0 && !requestOptions.body) {
requestOptions.body = ''

// temporary workaround for https://github.com/octokit/rest.js/issues/694
if (/\/notifications$/.test(requestOptions.url)) {
requestOptions.body = '{}'
requestOptions.headers['content-type'] = 'application/json; charset=utf-8'
}
}

if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
requestOptions.body = JSON.stringify(requestOptions.body)
}

let headers = {}

return fetch(requestOptions.url, pick(requestOptions, 'method', 'body', 'headers', 'timeout', 'agent'))

.then(response => {
for (const keyAndValue of response.headers.entries()) {
headers[keyAndValue[0]] = keyAndValue[1]
}

if (response.status === 204) {
if (response.status === 204 || response.status === 205) {
return
}

Expand Down

0 comments on commit c1fc675

Please sign in to comment.