通过restangular获取布尔响应(GET boolean response through restangular)

编程入门 行业动态 更新时间:2024-10-27 04:27:45
通过restangular获取布尔响应(GET boolean response through restangular)

我已经使用Jersey创建了一项休息服务。 该服务允许用户检查用户名是否已经可用或已被某人使用。

http://localhost:8080/rest/user/checkUname/uname

这返回true或false,它工作正常。

现在在我的用户界面中,我尝试在Angularjs中使用Restangular,其代码如下所示

var userBaseUrl = Restangular.all('user'); var valid = userBaseUrl.one('checkUname',uname).get();

但'有效'没有布尔值。

正如我在调试中看到的,所有执行都正常工作。

如何通过Restangular访问布尔响应?

I have created a rest service using Jersey. The service allows user to check if the username is already available or has been used by someone.

http://localhost:8080/rest/user/checkUname/uname

This returns true or false and it works fine.

Now in my UI I am trying to use the Restangular in Angularjs where my code is as follow

var userBaseUrl = Restangular.all('user'); var valid = userBaseUrl.one('checkUname',uname).get();

But 'valid' does not have a boolean value.

All the executions are working proper as I see in the debugging.

How do I access a boolean response through Restangular ?

最满意答案

尝试做到这一点:

Restangular.all('user').one('checkUname', uname).get().then( function (valid) { //check here } )

try to do this:

Restangular.all('user').one('checkUname', uname).get().then( function (valid) { //check here } )

更多推荐

本文发布于:2023-07-24 00:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1239029.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布尔   restangular   response   boolean

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!