Angular 2 with servicestack..

0 views
Skip to first unread message

Jose Antonio Carbonell Perez

unread,
Jan 23, 2017, 1:16:29 PM1/23/17
to Angular 2
I have a problem.. i don't know how to work with angular 2 and servicestack references, because i can't to link Angular 2 - typescript with servicestack.. if you have any information about the topic i would appreciate it... Bessings..

Tim Consolazio

unread,
Jan 23, 2017, 2:06:21 PM1/23/17
to Angular 2
Isn't servicestack a web services framework? I would think you'd just call those webservices via the usuall http get/post available in the Angular 2 HTTP service, same as any other exposed service endpoint. 

Jose Antonio Carbonell Perez

unread,
Jan 26, 2017, 8:09:20 AM1/26/17
to Angular 2
The problem is that when i sent http body in the POST, JSON.stringify() add me " in the body, when it's some like this "{body}.. You have had the same problem?.. Help me..!!

Tim Consolazio

unread,
Jan 26, 2017, 8:21:25 AM1/26/17
to Angular 2
Really need you clarify that statement. In the meantime though, take a look at this article. It's possible the problem is as simple as the header you are sending. "application/json" is the default for angular, but for instance, Java servlets don't understand it out-of-the-box. It's possible .Net doesn't either. 

(Yes I get you're not working with Java. But the issue may be the same, or related. That is, unless you really just have no experience with RPC and your code is just broken). 

http://www.tcoz.com/newtcoz/#/errata 

And look for the article:

Jose Antonio Carbonell Perez

unread,
Jan 26, 2017, 6:02:29 PM1/26/17
to Angular 2
I understand it, my get request it works perfectly, but is when i try to make a POST, sometime has happened to you? 

Tim Consolazio

unread,
Jan 26, 2017, 6:04:26 PM1/26/17
to Angular 2
Yes, get works fine. Post is what breaks because of the way POST sends data.

Jose Antonio Carbonell Perez

unread,
Jan 26, 2017, 6:10:18 PM1/26/17
to Angular 2
And you have some example that you are used?... because the problem is JSON.stringify... I'm sorry for the annoyance... 

Tim Consolazio

unread,
Jan 27, 2017, 7:48:30 AM1/27/17
to Angular 2
You'll need to post more detail of what is going on here. JSON.stringify will rarely "break" (it's usually JSON.parse that breaks because of invalid JSON, but JSON.stringify will pretty much try to stringify anything). 

I'd recommend posting a Plunkr or some such, or at least referencing the code in a github repo so we can look at it. Otherwise it's going to be impossible to understand what is going on. 

Jose Antonio Carbonell Perez

unread,
Jan 27, 2017, 11:17:28 AM1/27/17
to Angular 2
How i can to pass you my POST for you to see?.. because i am stop with that...

Tim Consolazio

unread,
Jan 27, 2017, 11:46:08 AM1/27/17
to Angular 2
From your descriptions, here is what I know:

- You are sending data to a POST handler. 
- That POST handler is receiving the data. 
- You are stringifying the data. 
- You are trying to use that stringified data. 
- Something is wrong with the stringified data, so you can't use it. 

What would be helpful to see:

The data BEFORE you send it. 
The POST itself (which you can get from browser dev tools)
The data AFTER the POST handler receives it, BEFORE you stringify it. 
The data AFTER you stringify it. 
What you are trying to do with that stringified data that isn't working. 

If you provide that info, I can help you. If you don't know how to provide this info, then I'm not sure what else I can do. 

Jose Antonio Carbonell Perez

unread,
Jan 30, 2017, 9:09:41 AM1/30/17
to Angular 2

Tim, This is my Component.

This is my Service (POST)..

If you need more information, tell me..




Tim Consolazio

unread,
Jan 30, 2017, 10:00:29 AM1/30/17
to Angular 2
I need to see a "console.log ( model )", before you stringify it. Copy exactly what you see in the console, all of it, and paste it here. 

Jose Antonio Carbonell Perez

unread,
Jan 30, 2017, 11:26:10 AM1/30/17
to Angular 2
Does not show me anything in the console.. What could it be?..

Jose Antonio Carbonell Perez

unread,
Jan 30, 2017, 11:30:18 AM1/30/17
to Angular 2

Before the return i put console.log(model).. and look you... 

Jose Antonio Carbonell Perez

unread,
Jan 30, 2017, 11:52:13 AM1/30/17
to Angular 2

Here is the problem.. You look the first (") before the first { .... 

Jose Antonio Carbonell Perez

unread,
Jan 30, 2017, 11:55:56 AM1/30/17
to Angular 2

The same problem of other way... 
Reply all
Reply to author
Forward
0 new messages