question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Population breaks when specify array of multiple objects (necessary for nested population)

See original GitHub issue

When using population the module has a bug regarding array of population objects. I have four schemas: games, characters, locations and events. The schema itself does not really matter. When I specify an array of strings for fields to be populated, it works.

WORKING

axios({
      method:'get',
      url: config.apiUri + '/game/' + id,
      params: {
        populate: ['characters', 'events', 'locations'],
      },
    })

If you want to do a nested populate you would need to specify a path. The following example also works (also the nested events field gets populated).

WORKING

axios({
      method:'get',
      url: config.apiUri + '/game/' + id,
      params: {
        populate: [{
          path: 'locations',
          populate: {
            path: 'events'
          },
        }],
      },
    })

However if you specify an array of objects as populate param, the population breaks and all populated fields return a null value. This happens regardless whether you do a nested population or not.

NOT WORKING

axios({
      method:'get',
      url: config.apiUri + '/game/' + id,
      params: {
        populate: [{
          path: 'locations',
          populate: {
            path: 'events'
          },
        }, {
          path: 'characters'
        }],
      },
    })

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
florianbepunktcommented, May 15, 2018

@Zertz Thank you, didn’t know about this not being standardized. Sorry for making a fuzz,

0reactions
Zertzcommented, May 13, 2018

Passing arrays in query strings isn’t standardized and axios seems to be generating a different format.

What I usually do is build a plain old JavaScript object and then JSON.stringify it into the query string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug - Error displaying nested arrays in the inspector
After the transition to 2020.3.6, there was a problem with displaying nested arrays if there are more than two of them in the...
Read more >
python - Unable to exit nested while loops - Stack Overflow
I am writing a program that tracks populations given birth and death rates. Each cell of the population is a 'dictionary' object that...
Read more >
Arrays - The Modern JavaScript Tutorial
Arrays. Objects allow you to store keyed collections of values. That's fine. But quite often we find that we need an ordered collection, ......
Read more >
breaking change: Can't use nested arrays or arrays of objects ...
Reporting a bug? In vue-i18n v8.0.0, I was able use nested arrays of objects to manage translatable content for "About" or "FAQ" pages....
Read more >
Flattening nested arrays - Amazon Athena
To flatten a nested array's elements into a single array of values, use the flatten function. This query returns a row for each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found