JavaScript this does not access http response object:property does not exist on type Object that does access mean

I have response object i just assigned to "this" object.

private data: Object = {};

this.http.post('url', { })
    .subscribe(
        res => {
            console.log(res);
            this.data = res;

            if(this.data.datacentersinfo.length) {}

...

If I access datacentersinfo object it saying property datacentersinfo does not exist on type Object. Because of this error, I am not able to generate the dist folder.

Answer:1

You have several solutions :

1 - type your data to any and don't instanciate it :

private data: any;

2 - change your condition :

if(this.data && this.data.datacentersinfo && this.data.datacentersinfo.length) {}

This should resolve your issue.

Answer:2

What do I need to add so that when a user clicks on the Current Period button, the entire area (which is shaded in the second image for clarity) is replaced with the content of the page controlled by ...

What do I need to add so that when a user clicks on the Current Period button, the entire area (which is shaded in the second image for clarity) is replaced with the content of the page controlled by ...

I'm using dynamodb npm to query dynamodb When I query as below, though I set limit as 12 items, It always returns 10 items TableDB .query(lang) .filter('users').in(['case1','case2']) ....

I'm using dynamodb npm to query dynamodb When I query as below, though I set limit as 12 items, It always returns 10 items TableDB .query(lang) .filter('users').in(['case1','case2']) ....

I have java script function which gives current lat long inside that function making an http post call like this "this.http.post" but the value of this null inside the function My code ngOnInit()...

I have java script function which gives current lat long inside that function making an http post call like this "this.http.post" but the value of this null inside the function My code ngOnInit()...

  1. c++ this pointer becomes null

I am trying to combine two queries in Mongoose into one. Right now, I'm doing this: User.find({ _id: req.body.userId }, (err, user) => { User.find({ username: decodedUser.username }, (err, ...

I am trying to combine two queries in Mongoose into one. Right now, I'm doing this: User.find({ _id: req.body.userId }, (err, user) => { User.find({ username: decodedUser.username }, (err, ...

  1. execute multiple queries in dbeaver
  2. execute multiple queries in python
  3. execute multiple queries in stored procedure
  4. execute multiple queries in mysql
  5. execute multiple queries in mysql php
  6. execute multiple queries in mysql python
  7. execute multiple queries in java
  8. execute multiple queries postgres
  9. execute multiple queries in oracle
  10. execute multiple queries in sqlite
  11. execute multiple queries in sql server
  12. execute multiple queries in c#
  13. execute multiple queries in hibernate
  14. execute multiple queries in one statement
  15. execute multiple queries in jdbc java
  16. execute multiple queries in php
  17. execute multiple queries in toad
  18. execute multiple queries in access
  19. execute multiple queries on a single connection c#
  20. execute multiple queries in talend