How to filter the SpaceX API (mongoDB find() based) by a nested array?! Tech Test
I'm stuck on a tech test where I need to call the spaceX API and filter all launches in the response based on an array of payloads including a specific nationality string. The the response normally has only a list of payload ids, but the full payload data is populated via options object.
Link to API docs:
https://github.com/r-spacex/SpaceX-API/blob/master/docs/queries.md
I've been going through all the mongoDB docs trying to get my head around the syntax, but keep either getting all data unfiltered, or none, or an error. Been trying for days, and the I know from the recruiter that others have failed because they failed to add in this specific filter in past tech tests. I'm currently getting this error:
This is the body I am sending:
Would really appreciate any suggestions.
GitHub
SpaceX-API/queries.md at master · r-spacex/SpaceX-API
:rocket: Open Source REST API for SpaceX launch, rocket, core, capsule, starlink, launchpad, and landing pad data. - SpaceX-API/queries.md at master · r-spacex/SpaceX-API
6 Replies
To clarify, I'm trying to avoid filtering locally so I can use the APIs built in pagination. Worst case I assume the best option is to query the payloads end-point instead to get a list of all launch ids and then query the Launch API with those. 🤷♂️
Try
nope. 200 status, but docs array is empty
I tried $in, $all, and $elemMatch and even $exists and none of them work for me lmao
returns nothing for me O_o
Thanks for trying. At least I can be satisfied it's not just me being stupid. I think it's due to the field being populated in the options. It can only be filtered on the payload id string 😭
The advice on stack overflow was "just change the API scheme" 😂
lmao
maybe ask gpt3