Retrieve the state of a konnector

Hello,

What did you do?

I would like to retrieve the konnector state, to advertise the application user if something went wrong and to alert him that the data displayed may be not the last one.

For that, I’m querying the trigger though the cozy harvest lib:

But today, the trigger has not the last state of the execution. That is why I tried to query the last jobs of the trigger and retrieve the state using cozy client:
client.query(client.find('io.cozy.jobs') .where({ 'message.konnector': slug }) .sortBy([{ finished_at: 'desc' }]) .limitBy(1))
(*) where client is an instance of the CozyClient

What happened?

The query return me an error:
Uncaught (in promise) TypeError: collection.find is not a function
at StackLink.executeQuery (StackLink.js:100)
at StackLink.request (StackLink.js:74)
at CozyLink.request (CozyLink.js:64)
at CozyClient._callee8$ (CozyClient.js:970)
at tryCatch (runtime.js:62)
at Generator.invoke [as _invoke] (runtime.js:296)
at Generator.prototype. [as next] (runtime.js:114)
at step (asyncToGenerator.js:17)
at asyncToGenerator.js:35
at new Promise ()

It seems that we are not able to query jobs using cozy-client.

More information

I also read about the trigger state. But it seems that the state is updated by the job. Have you some example on How it is done?