Angular 2+ mongoose, let on array doesn't work due to ID object

I am trying to do a let on an array of data that is requested from a mongoose server. This works if I don't return the ID object with the rest of the Json data. However I want to add the ID data as params to routernavigate to another component.

Is there an easy way of receiving the id as a string rather then an object?

1 answer

  • answered 2017-12-06 03:56 Anuruddha Thennakoon

    You can use following to stringify your object data

    JSON.parse(JSON.stringify(''));//use your result object as parameters

    as a example JSON.parse(JSON.stringify(result['_id']));