How to read object in subscribe (observable) -angular 62019 Community Moderator ElectionHow to watch for form changes in AngularBinding select element to object in AngularAngular 2 beta.17: Property 'map' does not exist on type 'Observable<Response>'What is the difference between Promises and Observables?Angular 2: Observable subscription not reading data correctlyComponent displays a blank screen before data is subscribed from ObservableAngular 2 Observable returning array out of orderSubscribe to Observable -> Filter -> Provide as ObservableAngular 5 subscribe and unsubscribe ObservableWhy observables in for loop work differently?

What is this diamond of every day?

Rationale to prefer local variables over instance variables?

Can the alpha, lambda values of a glmnet object output determine whether ridge or Lasso?

Finitely many repeated replacements

Why is a very small peak with larger m/z not considered to be the molecular ion?

What materials can be used to make a humanoid skin warm?

How to resolve: Reviewer #1 says remove section X vs. Reviewer #2 says expand section X

Having the player face themselves after the mid-game

Is a piano played in the same way as a harmonium?

I can't die. Who am I?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

From an axiomatic set theoric approach why can we take uncountable unions?

Specifying a starting column with colortbl package and xcolor

What ability score modifier does a javelin's damage use?

What would be the most expensive material to an intergalactic society?

Outlet with 3 sets of wires

PTIJ: Why does only a Shor Tam ask at the Seder, and not a Shor Mu'ad?

How does Ehrenfest's theorem apply to the quantum harmonic oscillator?

Virginia employer terminated employee and wants signing bonus returned

School performs periodic password audits. Is my password compromised?

Is it possible that a question has only two answers?

Professor forcing me to attend a conference, I can't afford even with 50% funding

Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?

How do spaceships determine each other's mass in space?



How to read object in subscribe (observable) -angular 6



2019 Community Moderator ElectionHow to watch for form changes in AngularBinding select element to object in AngularAngular 2 beta.17: Property 'map' does not exist on type 'Observable<Response>'What is the difference between Promises and Observables?Angular 2: Observable subscription not reading data correctlyComponent displays a blank screen before data is subscribed from ObservableAngular 2 Observable returning array out of orderSubscribe to Observable -> Filter -> Provide as ObservableAngular 5 subscribe and unsubscribe ObservableWhy observables in for loop work differently?










0















I'm working on a project in angular 6 and i'm facing to a problem !
I want to read the content of an object which is in my observable like this:



this.myService.getOne().subscribe(e => 
this.e = e;
console.log(this.e);
console.log(this.e.id); // result => undefined
);


I can see this.e which look like that:



"id":"1", "name":"myName", ...


But this.e.id is 'undefined', same thing when i write this.e['id'].



Did you have any idea ?










share|improve this question
























  • console gives the correct output?

    – emkay
    Mar 6 at 14:08











  • For the e, i see the entire object in the console but for e.id, i see 'undefined' whereas i can see 'id' into e

    – dervillers mattéo
    Mar 6 at 14:11







  • 1





    By naming of' getAll(); I would assume you are getting and array so maybe e[0].id would do the trick. But until we see what your actual response you get this is just a guess.

    – Bruno
    Mar 6 at 14:12











  • Sorry Bruno, i wanted to write 'getOne()', i just have an object in the output

    – dervillers mattéo
    Mar 6 at 14:14






  • 1





    how can e be undefined since you're logging it?

    – gyc
    Mar 6 at 14:44















0















I'm working on a project in angular 6 and i'm facing to a problem !
I want to read the content of an object which is in my observable like this:



this.myService.getOne().subscribe(e => 
this.e = e;
console.log(this.e);
console.log(this.e.id); // result => undefined
);


I can see this.e which look like that:



"id":"1", "name":"myName", ...


But this.e.id is 'undefined', same thing when i write this.e['id'].



Did you have any idea ?










share|improve this question
























  • console gives the correct output?

    – emkay
    Mar 6 at 14:08











  • For the e, i see the entire object in the console but for e.id, i see 'undefined' whereas i can see 'id' into e

    – dervillers mattéo
    Mar 6 at 14:11







  • 1





    By naming of' getAll(); I would assume you are getting and array so maybe e[0].id would do the trick. But until we see what your actual response you get this is just a guess.

    – Bruno
    Mar 6 at 14:12











  • Sorry Bruno, i wanted to write 'getOne()', i just have an object in the output

    – dervillers mattéo
    Mar 6 at 14:14






  • 1





    how can e be undefined since you're logging it?

    – gyc
    Mar 6 at 14:44













0












0








0








I'm working on a project in angular 6 and i'm facing to a problem !
I want to read the content of an object which is in my observable like this:



this.myService.getOne().subscribe(e => 
this.e = e;
console.log(this.e);
console.log(this.e.id); // result => undefined
);


I can see this.e which look like that:



"id":"1", "name":"myName", ...


But this.e.id is 'undefined', same thing when i write this.e['id'].



Did you have any idea ?










share|improve this question
















I'm working on a project in angular 6 and i'm facing to a problem !
I want to read the content of an object which is in my observable like this:



this.myService.getOne().subscribe(e => 
this.e = e;
console.log(this.e);
console.log(this.e.id); // result => undefined
);


I can see this.e which look like that:



"id":"1", "name":"myName", ...


But this.e.id is 'undefined', same thing when i write this.e['id'].



Did you have any idea ?







angular typescript angular6 observable subscribe






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 14:44







dervillers mattéo

















asked Mar 6 at 14:00









dervillers mattéodervillers mattéo

14




14












  • console gives the correct output?

    – emkay
    Mar 6 at 14:08











  • For the e, i see the entire object in the console but for e.id, i see 'undefined' whereas i can see 'id' into e

    – dervillers mattéo
    Mar 6 at 14:11







  • 1





    By naming of' getAll(); I would assume you are getting and array so maybe e[0].id would do the trick. But until we see what your actual response you get this is just a guess.

    – Bruno
    Mar 6 at 14:12











  • Sorry Bruno, i wanted to write 'getOne()', i just have an object in the output

    – dervillers mattéo
    Mar 6 at 14:14






  • 1





    how can e be undefined since you're logging it?

    – gyc
    Mar 6 at 14:44

















  • console gives the correct output?

    – emkay
    Mar 6 at 14:08











  • For the e, i see the entire object in the console but for e.id, i see 'undefined' whereas i can see 'id' into e

    – dervillers mattéo
    Mar 6 at 14:11







  • 1





    By naming of' getAll(); I would assume you are getting and array so maybe e[0].id would do the trick. But until we see what your actual response you get this is just a guess.

    – Bruno
    Mar 6 at 14:12











  • Sorry Bruno, i wanted to write 'getOne()', i just have an object in the output

    – dervillers mattéo
    Mar 6 at 14:14






  • 1





    how can e be undefined since you're logging it?

    – gyc
    Mar 6 at 14:44
















console gives the correct output?

– emkay
Mar 6 at 14:08





console gives the correct output?

– emkay
Mar 6 at 14:08













For the e, i see the entire object in the console but for e.id, i see 'undefined' whereas i can see 'id' into e

– dervillers mattéo
Mar 6 at 14:11






For the e, i see the entire object in the console but for e.id, i see 'undefined' whereas i can see 'id' into e

– dervillers mattéo
Mar 6 at 14:11





1




1





By naming of' getAll(); I would assume you are getting and array so maybe e[0].id would do the trick. But until we see what your actual response you get this is just a guess.

– Bruno
Mar 6 at 14:12





By naming of' getAll(); I would assume you are getting and array so maybe e[0].id would do the trick. But until we see what your actual response you get this is just a guess.

– Bruno
Mar 6 at 14:12













Sorry Bruno, i wanted to write 'getOne()', i just have an object in the output

– dervillers mattéo
Mar 6 at 14:14





Sorry Bruno, i wanted to write 'getOne()', i just have an object in the output

– dervillers mattéo
Mar 6 at 14:14




1




1





how can e be undefined since you're logging it?

– gyc
Mar 6 at 14:44





how can e be undefined since you're logging it?

– gyc
Mar 6 at 14:44












1 Answer
1






active

oldest

votes


















0














I founded the problem, i had 2 things in more into my getOne() method:



I changed the method from



getOne(): Observable<myObject> ...


to



getOne() ...


I changed the return from



this.get<myObject>(url, httpOptions); //httpOptions contained headers and response type 'text' as 'json' 


to



this.get<myObject>(url);


Now its functional, thank you for your help ! :)






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',
    autoActivateHeartbeat: false,
    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%2f55024890%2fhow-to-read-object-in-subscribe-observable-angular-6%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I founded the problem, i had 2 things in more into my getOne() method:



    I changed the method from



    getOne(): Observable<myObject> ...


    to



    getOne() ...


    I changed the return from



    this.get<myObject>(url, httpOptions); //httpOptions contained headers and response type 'text' as 'json' 


    to



    this.get<myObject>(url);


    Now its functional, thank you for your help ! :)






    share|improve this answer



























      0














      I founded the problem, i had 2 things in more into my getOne() method:



      I changed the method from



      getOne(): Observable<myObject> ...


      to



      getOne() ...


      I changed the return from



      this.get<myObject>(url, httpOptions); //httpOptions contained headers and response type 'text' as 'json' 


      to



      this.get<myObject>(url);


      Now its functional, thank you for your help ! :)






      share|improve this answer

























        0












        0








        0







        I founded the problem, i had 2 things in more into my getOne() method:



        I changed the method from



        getOne(): Observable<myObject> ...


        to



        getOne() ...


        I changed the return from



        this.get<myObject>(url, httpOptions); //httpOptions contained headers and response type 'text' as 'json' 


        to



        this.get<myObject>(url);


        Now its functional, thank you for your help ! :)






        share|improve this answer













        I founded the problem, i had 2 things in more into my getOne() method:



        I changed the method from



        getOne(): Observable<myObject> ...


        to



        getOne() ...


        I changed the return from



        this.get<myObject>(url, httpOptions); //httpOptions contained headers and response type 'text' as 'json' 


        to



        this.get<myObject>(url);


        Now its functional, thank you for your help ! :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 6 at 15:09









        dervillers mattéodervillers mattéo

        14




        14





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024890%2fhow-to-read-object-in-subscribe-observable-angular-6%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







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко