Browse Source

Do not assign to undefined response

http2
Vsevolod Strukchinsky 10 years ago
parent
commit
bdc1bfb2b8
  1. 2
      index.js
  2. 7
      test/test-helpers.js

2
index.js

@ -106,7 +106,9 @@ function asCallback(opts, cb) {
function asPromise(opts) {
return new PinkiePromise(function (resolve, reject) {
asCallback(opts, function (err, data, response) {
if (response) {
response.body = data;
}
if (err) {
err.response = response;

7
test/test-helpers.js

@ -28,7 +28,7 @@ test('callback mode', function (t) {
});
test('promise mode', function (t) {
t.plan(2);
t.plan(3);
got.get(s.url)
.then(function (res) {
@ -39,6 +39,11 @@ test('promise mode', function (t) {
.catch(function (err) {
t.equal(err.response.body, 'not found');
});
got.get('.com')
.catch(function (err) {
t.ok(err);
});
});
test('cleanup', function (t) {

Loading…
Cancel
Save