API Documentation / @pinia/colada / PiniaColadaQueryHooksPlugin
Function: PiniaColadaQueryHooksPlugin()
ts
function PiniaColadaQueryHooksPlugin(options): PiniaColadaPlugin
Allows to add global hooks to all queries:
onSuccess
: called when a query is successfulonError
: called when a query throws an erroronSettled
: called when a query is settled (either successfully or with an error)
Parameters
options
PiniaColadaQueryHooksPluginOptions
Pinia Colada Query Hooks plugin options
Returns
Example
ts
import { PiniaColada, PiniaColadaQueryHooksPlugin } from '@pinia/colada'
const app = createApp(App)
// app setup with other plugins
app.use(PiniaColada, {
plugins: [
PiniaColadaQueryHooksPlugin({
onError(error, entry) {
// ...
},
}),
],
})