TypeError:undefined不是对象 - git推送失败
问题描述:
我有一个角码在机器上运行正常,没有错误,然后我想提交到git的更改,我的提交cmd运行成功但推失败说:TypeError:undefined不是对象 - git推送失败
PhantomJS 2.1.1(Windows 7的0.0.0)控制器:BasicInfo ...控制器导航...保存并去总结失败 类型错误:不确定是不是(评估 'data.responseMessage')的对象
data.responseMessage保存布尔值。我想添加一个条件检查未定义如下,但没有运气。
if(data.responseMessage !== 'Undefined' {
res = data.responseMessage;
}
我的实际部分代码是在这里:
function save() {
if(vm.basicInfoForm.$valid) {
blockUI.start('Saving personal information');
employeeService.setEmployee(vm.employee)
.then(function Success(data) {
res = data.responseMessage;
为data.response值从employee.js文件来和下面是代码:
function setEmployee(employee) {
_employee = null;
return Restangular.one('someURL').customPUT(employee)
.then(function Success(data) {
var responseData = {
responseMessage: data.isAddressChanged,
employeeData : _employee
};
return responseData;
})
['catch'](function Failure() {
var responseData = {
responseMessage: false,
employeeData : null
};
return responseData;
});
}
我认为这可能是因为一些测试用例失败而git push。 任何帮助表示赞赏!
谢谢, Haseena
答
我可以通过存储在res仅数据对象作为
res=data;
后来在我用
if(res.responsemessage.isAddressChange) {}
如果'data.responseMessage代码解决问题'是一个布尔值,然后'data.responseMessage!=='Undefined''将始终返回* true *,因为您严格将一个字符串与一个布尔值进行比较(并且不同的类型从不严格等价)。但是你的错误源自* data *未定义(显然)。 – RobG
我试过条件检查,但稍后在 –
上删除了它,数据来源为question.response –