1

I Have Tried

http.get('http://192.168.0.26:9000/api/task/counttask?projectid=-1&Teamid=-1&RoleId=-1&status=1&PID=-1&mytasks=0&alltasks=0&page=1&row=15&priorityid=-1&typeid=-1&taskname=&JSON&_=1471520478215')

    .map((res: Response) => res.json())
    .subscribe(res => this.result = res); 
     alert(this.result);

I am Getting Error But if You run this below Url in Browser it will give you the output

192.168.0.26:9000/api/task/counttask?projectid=-1&Teamid=-1&RoleId=-1&status=1&PID=-1&mytasks=0&alltasks=0&page=1&row=15&priorityid=-1&typeid=-1&taskname=&JSON&_=1471520478215

How to Handle this Request ??

5
  • In your map function, it shouldn't be .map((res) => res.json())? Commented Aug 19, 2016 at 8:22
  • What i have to give on that place ? Commented Aug 19, 2016 at 8:24
  • (res: Response) => res.json() is not correct in syntax. I think that it should be res => res.json() Commented Aug 19, 2016 at 8:26
  • (res: Response) => res.json() is totally fine and won't make any difference in the produced JavaScript Commented Aug 19, 2016 at 8:27
  • @j2L4e Give me some i idea ... post the answer with the below url ... i will upvote ... Commented Aug 19, 2016 at 8:29

1 Answer 1

1

First things first: It'd be nice to know the actual error.

Your alert() is executed right away. So the request hasn't finished yet. Try this:

.subscribe(res => {
  this.result = res;
  console.log(this.result);
}); 

edit: you should use console.log (or an actual debugger), because alert() does not resolve objects. It might just say "[object Object]".

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot Its Working ... I cannot upvote because it needs atleast 15 reputation ....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.