8000 fix http 204 no content · core-api/javascript-client@fe78d3a · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Commit fe78d3a

Browse files
committed
fix http 204 no content
1 parent f8913a1 commit fe78d3a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/transports/http.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class HTTPTransport {
123123

124124
return this.fetch(request.url, request.options)
125125
.then(function (response) {
126+
if (response.status === 204) {
127+
return
128+
}
126129
return parseResponse(response, decoders, responseCallback)
127130
.then(function (data) {
128131
if (response.ok) {

tests/transports/http.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,16 @@ describe('Test the HTTPTransport', function () {
302302
expect(responseCallback).toHaveBeenCalledTimes(1)
303303
})
304304
})
305+
306+
it('should not throw on "204 no content"', function () {
307+
const url = 'http://www.example.com/'
308+
const link = new document.Link(url, 'delete')
309+
const transport = new transports.HTTPTransport({
310+
fetch: testUtils.mockedFetch(null, null, 204)
311+
})
312+
const params = {}
313+
314+
return transport.action(link, decoders, params)
315+
.catch(error => expect(error).toBeNull())
316+
})
305317
})

0 commit comments

Comments
 (0)
0