Angular 6 return mapping missing
up vote
0
down vote
favorite
Upgrading a project from Angular 4 to 6 and having some trouble getting my return to work. My json comes in like
{
"incomingViolationList":[{"productName": "Mirror",…],
"incomingViolationListCount": 67
}
My service call use to look like this but in A6 .map no longer works.
return this.http.get('MappViolations/MappViolations?', options)
.map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
});
I have starting my new service call but am at a loss how to seperate into "data" and "total"
return this.http.get<IncommingViolations>
(AppSettings.API_ENDPOINT + 'MappViolations/MappViolations?', { params });
angular angular-httpclient
add a comment |
up vote
0
down vote
favorite
Upgrading a project from Angular 4 to 6 and having some trouble getting my return to work. My json comes in like
{
"incomingViolationList":[{"productName": "Mirror",…],
"incomingViolationListCount": 67
}
My service call use to look like this but in A6 .map no longer works.
return this.http.get('MappViolations/MappViolations?', options)
.map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
});
I have starting my new service call but am at a loss how to seperate into "data" and "total"
return this.http.get<IncommingViolations>
(AppSettings.API_ENDPOINT + 'MappViolations/MappViolations?', { params });
angular angular-httpclient
But what is happening?
– Antoniossss
Nov 7 at 18:33
in the A4 version .map is no longer a option
– Alex D
Nov 7 at 18:33
2
use pipe and then map.
– Antoniossss
Nov 7 at 18:34
Perhaps helpfully, read github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md It comes with a change in rxjs, where chained dot-operators were replaced with pipe/taps.
– msanford
Nov 7 at 18:38
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Upgrading a project from Angular 4 to 6 and having some trouble getting my return to work. My json comes in like
{
"incomingViolationList":[{"productName": "Mirror",…],
"incomingViolationListCount": 67
}
My service call use to look like this but in A6 .map no longer works.
return this.http.get('MappViolations/MappViolations?', options)
.map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
});
I have starting my new service call but am at a loss how to seperate into "data" and "total"
return this.http.get<IncommingViolations>
(AppSettings.API_ENDPOINT + 'MappViolations/MappViolations?', { params });
angular angular-httpclient
Upgrading a project from Angular 4 to 6 and having some trouble getting my return to work. My json comes in like
{
"incomingViolationList":[{"productName": "Mirror",…],
"incomingViolationListCount": 67
}
My service call use to look like this but in A6 .map no longer works.
return this.http.get('MappViolations/MappViolations?', options)
.map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
});
I have starting my new service call but am at a loss how to seperate into "data" and "total"
return this.http.get<IncommingViolations>
(AppSettings.API_ENDPOINT + 'MappViolations/MappViolations?', { params });
angular angular-httpclient
angular angular-httpclient
edited Nov 7 at 18:41
msanford
6,43864365
6,43864365
asked Nov 7 at 18:29
Alex D
11011
11011
But what is happening?
– Antoniossss
Nov 7 at 18:33
in the A4 version .map is no longer a option
– Alex D
Nov 7 at 18:33
2
use pipe and then map.
– Antoniossss
Nov 7 at 18:34
Perhaps helpfully, read github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md It comes with a change in rxjs, where chained dot-operators were replaced with pipe/taps.
– msanford
Nov 7 at 18:38
add a comment |
But what is happening?
– Antoniossss
Nov 7 at 18:33
in the A4 version .map is no longer a option
– Alex D
Nov 7 at 18:33
2
use pipe and then map.
– Antoniossss
Nov 7 at 18:34
Perhaps helpfully, read github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md It comes with a change in rxjs, where chained dot-operators were replaced with pipe/taps.
– msanford
Nov 7 at 18:38
But what is happening?
– Antoniossss
Nov 7 at 18:33
But what is happening?
– Antoniossss
Nov 7 at 18:33
in the A4 version .map is no longer a option
– Alex D
Nov 7 at 18:33
in the A4 version .map is no longer a option
– Alex D
Nov 7 at 18:33
2
2
use pipe and then map.
– Antoniossss
Nov 7 at 18:34
use pipe and then map.
– Antoniossss
Nov 7 at 18:34
Perhaps helpfully, read github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md It comes with a change in rxjs, where chained dot-operators were replaced with pipe/taps.
– msanford
Nov 7 at 18:38
Perhaps helpfully, read github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md It comes with a change in rxjs, where chained dot-operators were replaced with pipe/taps.
– msanford
Nov 7 at 18:38
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
In Angular 6 there is HttpClient used instead of Http service
Using HttpClient the response object is a JSON by default, so there's no need to parse it anymore (
response.json()
is not needed)
Also if you update RxJS 6 with Angular 6 update it will look something like below pipe
able operators.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map((response: any) => ({
data: response.incomingViolationList,
total: response..incomingViolationListCount
})
);
ok, I think this is almost there. I am getting the following error. [ts] Property 'incomingViolationList' does not exist on type 'Object'.
– Alex D
Nov 7 at 18:56
@AlexD just makeresponse
type ofany
or specific type..
– Pankaj Parkar
Nov 7 at 18:58
or usemap((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
– Pankaj Parkar
Nov 7 at 18:59
add a comment |
up vote
1
down vote
In Angular 6, you will be using HttpClient which returns the json response by default. So you can remove json from the response.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => ({
data: response.incomingViolationList, //<-- remove json
total: response..incomingViolationListCount //<-- remove json
})
);
I am using httpclient. But this is the A4 code. How do I translate from .map down into A6?
– Alex D
Nov 7 at 18:35
updated the answer
– Sunil Singh
Nov 7 at 18:37
add a comment |
up vote
-1
down vote
So you have stated in the comment that your case is that map is not an option. Well actually it still is, but it is used slightly different way
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
}));
Notice usage of pipe
directly on observable insteed of map
.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
In Angular 6 there is HttpClient used instead of Http service
Using HttpClient the response object is a JSON by default, so there's no need to parse it anymore (
response.json()
is not needed)
Also if you update RxJS 6 with Angular 6 update it will look something like below pipe
able operators.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map((response: any) => ({
data: response.incomingViolationList,
total: response..incomingViolationListCount
})
);
ok, I think this is almost there. I am getting the following error. [ts] Property 'incomingViolationList' does not exist on type 'Object'.
– Alex D
Nov 7 at 18:56
@AlexD just makeresponse
type ofany
or specific type..
– Pankaj Parkar
Nov 7 at 18:58
or usemap((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
– Pankaj Parkar
Nov 7 at 18:59
add a comment |
up vote
2
down vote
In Angular 6 there is HttpClient used instead of Http service
Using HttpClient the response object is a JSON by default, so there's no need to parse it anymore (
response.json()
is not needed)
Also if you update RxJS 6 with Angular 6 update it will look something like below pipe
able operators.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map((response: any) => ({
data: response.incomingViolationList,
total: response..incomingViolationListCount
})
);
ok, I think this is almost there. I am getting the following error. [ts] Property 'incomingViolationList' does not exist on type 'Object'.
– Alex D
Nov 7 at 18:56
@AlexD just makeresponse
type ofany
or specific type..
– Pankaj Parkar
Nov 7 at 18:58
or usemap((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
– Pankaj Parkar
Nov 7 at 18:59
add a comment |
up vote
2
down vote
up vote
2
down vote
In Angular 6 there is HttpClient used instead of Http service
Using HttpClient the response object is a JSON by default, so there's no need to parse it anymore (
response.json()
is not needed)
Also if you update RxJS 6 with Angular 6 update it will look something like below pipe
able operators.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map((response: any) => ({
data: response.incomingViolationList,
total: response..incomingViolationListCount
})
);
In Angular 6 there is HttpClient used instead of Http service
Using HttpClient the response object is a JSON by default, so there's no need to parse it anymore (
response.json()
is not needed)
Also if you update RxJS 6 with Angular 6 update it will look something like below pipe
able operators.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map((response: any) => ({
data: response.incomingViolationList,
total: response..incomingViolationListCount
})
);
edited Nov 7 at 18:58
answered Nov 7 at 18:32
Pankaj Parkar
111k15157232
111k15157232
ok, I think this is almost there. I am getting the following error. [ts] Property 'incomingViolationList' does not exist on type 'Object'.
– Alex D
Nov 7 at 18:56
@AlexD just makeresponse
type ofany
or specific type..
– Pankaj Parkar
Nov 7 at 18:58
or usemap((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
– Pankaj Parkar
Nov 7 at 18:59
add a comment |
ok, I think this is almost there. I am getting the following error. [ts] Property 'incomingViolationList' does not exist on type 'Object'.
– Alex D
Nov 7 at 18:56
@AlexD just makeresponse
type ofany
or specific type..
– Pankaj Parkar
Nov 7 at 18:58
or usemap((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
– Pankaj Parkar
Nov 7 at 18:59
ok, I think this is almost there. I am getting the following error. [ts] Property 'incomingViolationList' does not exist on type 'Object'.
– Alex D
Nov 7 at 18:56
ok, I think this is almost there. I am getting the following error. [ts] Property 'incomingViolationList' does not exist on type 'Object'.
– Alex D
Nov 7 at 18:56
@AlexD just make
response
type of any
or specific type..– Pankaj Parkar
Nov 7 at 18:58
@AlexD just make
response
type of any
or specific type..– Pankaj Parkar
Nov 7 at 18:58
or use
map((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
– Pankaj Parkar
Nov 7 at 18:59
or use
map((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
– Pankaj Parkar
Nov 7 at 18:59
add a comment |
up vote
1
down vote
In Angular 6, you will be using HttpClient which returns the json response by default. So you can remove json from the response.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => ({
data: response.incomingViolationList, //<-- remove json
total: response..incomingViolationListCount //<-- remove json
})
);
I am using httpclient. But this is the A4 code. How do I translate from .map down into A6?
– Alex D
Nov 7 at 18:35
updated the answer
– Sunil Singh
Nov 7 at 18:37
add a comment |
up vote
1
down vote
In Angular 6, you will be using HttpClient which returns the json response by default. So you can remove json from the response.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => ({
data: response.incomingViolationList, //<-- remove json
total: response..incomingViolationListCount //<-- remove json
})
);
I am using httpclient. But this is the A4 code. How do I translate from .map down into A6?
– Alex D
Nov 7 at 18:35
updated the answer
– Sunil Singh
Nov 7 at 18:37
add a comment |
up vote
1
down vote
up vote
1
down vote
In Angular 6, you will be using HttpClient which returns the json response by default. So you can remove json from the response.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => ({
data: response.incomingViolationList, //<-- remove json
total: response..incomingViolationListCount //<-- remove json
})
);
In Angular 6, you will be using HttpClient which returns the json response by default. So you can remove json from the response.
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => ({
data: response.incomingViolationList, //<-- remove json
total: response..incomingViolationListCount //<-- remove json
})
);
edited Nov 7 at 18:36
answered Nov 7 at 18:34
Sunil Singh
5,5551625
5,5551625
I am using httpclient. But this is the A4 code. How do I translate from .map down into A6?
– Alex D
Nov 7 at 18:35
updated the answer
– Sunil Singh
Nov 7 at 18:37
add a comment |
I am using httpclient. But this is the A4 code. How do I translate from .map down into A6?
– Alex D
Nov 7 at 18:35
updated the answer
– Sunil Singh
Nov 7 at 18:37
I am using httpclient. But this is the A4 code. How do I translate from .map down into A6?
– Alex D
Nov 7 at 18:35
I am using httpclient. But this is the A4 code. How do I translate from .map down into A6?
– Alex D
Nov 7 at 18:35
updated the answer
– Sunil Singh
Nov 7 at 18:37
updated the answer
– Sunil Singh
Nov 7 at 18:37
add a comment |
up vote
-1
down vote
So you have stated in the comment that your case is that map is not an option. Well actually it still is, but it is used slightly different way
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
}));
Notice usage of pipe
directly on observable insteed of map
.
add a comment |
up vote
-1
down vote
So you have stated in the comment that your case is that map is not an option. Well actually it still is, but it is used slightly different way
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
}));
Notice usage of pipe
directly on observable insteed of map
.
add a comment |
up vote
-1
down vote
up vote
-1
down vote
So you have stated in the comment that your case is that map is not an option. Well actually it still is, but it is used slightly different way
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
}));
Notice usage of pipe
directly on observable insteed of map
.
So you have stated in the comment that your case is that map is not an option. Well actually it still is, but it is used slightly different way
return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map(response => <GridDataResult>{
data: response.json().incomingViolationList,
total: response.json().incomingViolationListCount
}));
Notice usage of pipe
directly on observable insteed of map
.
answered Nov 7 at 18:35
Antoniossss
14.7k12150
14.7k12150
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195623%2fangular-6-return-mapping-missing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
But what is happening?
– Antoniossss
Nov 7 at 18:33
in the A4 version .map is no longer a option
– Alex D
Nov 7 at 18:33
2
use pipe and then map.
– Antoniossss
Nov 7 at 18:34
Perhaps helpfully, read github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md It comes with a change in rxjs, where chained dot-operators were replaced with pipe/taps.
– msanford
Nov 7 at 18:38