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 });









share|improve this question
























  • 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

















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 });









share|improve this question
























  • 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















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 });









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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




















  • 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














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 pipeable operators.



return this.http.get('MappViolations/MappViolations?', options)
.pipe(
map((response: any) => ({
data: response.incomingViolationList,
total: response..incomingViolationListCount
})
);





share|improve this answer























  • 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










  • or use map((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
    – Pankaj Parkar
    Nov 7 at 18:59


















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
})


);






share|improve this answer























  • 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


















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.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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 pipeable operators.



    return this.http.get('MappViolations/MappViolations?', options)
    .pipe(
    map((response: any) => ({
    data: response.incomingViolationList,
    total: response..incomingViolationListCount
    })
    );





    share|improve this answer























    • 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










    • or use map((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
      – Pankaj Parkar
      Nov 7 at 18:59















    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 pipeable operators.



    return this.http.get('MappViolations/MappViolations?', options)
    .pipe(
    map((response: any) => ({
    data: response.incomingViolationList,
    total: response..incomingViolationListCount
    })
    );





    share|improve this answer























    • 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










    • or use map((response: {incomingViolationList: any, incomingViolationListCount: any}) => ({
      – Pankaj Parkar
      Nov 7 at 18:59













    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 pipeable operators.



    return this.http.get('MappViolations/MappViolations?', options)
    .pipe(
    map((response: any) => ({
    data: response.incomingViolationList,
    total: response..incomingViolationListCount
    })
    );





    share|improve this answer














    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 pipeable operators.



    return this.http.get('MappViolations/MappViolations?', options)
    .pipe(
    map((response: any) => ({
    data: response.incomingViolationList,
    total: response..incomingViolationListCount
    })
    );






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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 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


















    • 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










    • or use map((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












    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
    })


    );






    share|improve this answer























    • 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















    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
    })


    );






    share|improve this answer























    • 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













    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
    })


    );






    share|improve this answer














    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
    })


    );







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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


















    • 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










    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 7 at 18:35









        Antoniossss

        14.7k12150




        14.7k12150






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            這個網誌中的熱門文章

            Hercules Kyvelos

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud