如何调用 rest api in angularjs which returns boolean

How call rest api in angularjs which returns boolean

我休息 api return true/false,我在邮递员中称我的休息 api 并且有效 return 是真的或假的。 我需要在 angularjs 中调用此服务, 我应该在我的 angular js 中做些什么来使它成为 return true/false,因为现在它 returnsobjewct 对象。

function checkIsActive() {            
    return $resource('http://localhost:8080/myservice/v1/testService').query().$promise;
}

对于 return 布尔值的 API,使用 $http 服务:

function checkIsActive() {            
    return $http.get('http://localhost:8080/myservice/v1/testService');
}

.query 操作方法的 $resource 服务 returns 数组和 .get 操作方法的对象。


when i have console.log(myService.checkIsActive()); then it print [object Object] still it does not return boolean.

请记住,服务 return 是一个承诺,需要从中提取数据:

var promise = myService.checkIsActive();
promise.then(function(response) {
    console.log(response.data);
};