Hi @yogi - when I put {{ error }}
as you suggested, it's pulling the error response body - see screenshot below!
It looks like data.error has the full http response body mapped to itâŚ
@gilcrest Does using {{ error }}
and {{ data.error.message }}
work for your use case then?
Perhaps youâd have to do {{ JSON.parse(error.error.message) }}
(not sure about the exact code here, itâd be some permutation of this).
Hi @yogi - I just tested and it seems I can use the below as a workaround. Ideally, I think it makes more sense to be able to access the statusCode and key off that, but this will work in my use case as my API error response body is always the same structure. Are you planning to allow access to the statusCode? Eventually, every one of my queries will be rekeyed to this logic, so I'm wondering if that will eventually work. The nice thing about the statusCode is that it's a good clean boolean to key off of - either the status code is 400, etc. or it's not (e.g. 200). In the case of having to key off the error message itself, in the cases where the query is successful, the condition shows a problem because data.error is undefined. It still works, because it's not truthy, but the statusCode is more rock solid. Know what I mean?
Thanks again!
Dan
The other thing to consider is that your placeholder text for Failure conditions actually references data.statusCode === 400
(see below):
If you're not going to support this, you should update this as it's confusing...
Thanks!
Dan
@gilcrest weâll soon be pushing out fixes to this! The copy will change a little bit and youâll be able to access the status code inside the metadata
object
Great - thanks, let me know whenever - Iâll give it another test!
You should be able to test out using metadata
now!
Related to this, how do I treat a 404 error as a success and still run the transformer?
Even though Iâve specified my failure condition ({{ metadata.status !== 404 && metadata.status !== 200}}
) and it isnât fulfilled, I still get a warning during development and the transformer isnât run.
@bfelbo Hi and thanks for writing in!
Could we learn a bit more about your usecase? Specifically Iâm curious about:
- generally what your request is returning
- what you have in your transformer
- why and when youâd want to mark this failure as a success
- do expect this query to fail and get marked as success all the time or just some of the time?
Currently this feature doesnât support turning failures into successes but lets see if we can get you a work around or if we can implement this somehow
Thanks @yogi. Weâre doing a lookup for whether someone is in our Front email contact book. Itâs completely fine if theyâre not - we just need to know if thatâs the case.
Our transformer is simple: return { id: data.id, name: data.name }
. Weâd like these to just be undefined in the event of a 404 error. The main issue is that it adds more complexity in other components / queries to do an if/else based on whetherâs there an error. Moreover, itâs confusing for other devs to see these (unexpected, but normal) errors popping up while developing.
Weâll survive for now, but would be awesome to have in the future Thanks for building a super useful product!