Typeerror: Cannot Match Against 'undefined' Or 'null'
Code client.createPet(pet, (err, {name, breed, age}) => { if (err) { return t.error(err, 'no error') } t.equal(pet, {name, breed, age}, 'should be equivalent') }) Err
Solution 1:
this error should only arise if the array or object being destructured or its children is
undefined
ornull
.
Exactly. In your case, the object being destructured is either undefined
or null
. For example,
function test(err, {a, b, c}) {
console.log(err, a, b, c);
}
test(1, {a: 2, b: 3, c: 4});
// 1 2 3 4test(1, {});
// 1 undefined undefined undefinedtest(1);
// TypeError: Cannot match against 'undefined' or 'null'.
Post a Comment for "Typeerror: Cannot Match Against 'undefined' Or 'null'"