Any standard way to ensure that non-existence of path does not result in an API error

Options

Hi! In an array of objects, some elements might have a missing path (or diff structure) which leads to failing of the entire API. Can it be mitigated somehow?

Eg: [{"id":1,"name":"alpha","score":90},{"id":2,"name":"beta"}]

If I am running through a loop and accessing score path, I want my API to accept it as null/empty rather than generating an error that stops the whole API.

Best Answer

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Answer ✓
    Options

    Hi,

    try to use "get" filter instead of dot notation. It will allow you to assign a value like "null" to a path if Xano will not find it in object.