Category: Datasources
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Disable Appsmith Debug Toasts and Display Custom Message for Failed Query

Issue

I am having trouble disabling the default error Toasts in Appsmith when an action fails. I want to configure my own error messages for when an action fails, but I can't find the setting to do so. I would like to disable the default error Toasts and add my own custom error message for an API call on a button.

Resolution

To disable the default error toasts in Appsmith and add your own custom error messages for failed actions, you can use an async JS function inside a JS Object and run the query inside this function. In case the query fails, you can display a custom error message using the showAlert() method.

 Here's an example where the error returned by the query/API is included in the custom error message:

async runQuery() {  
		Query1.run(() => {}, (err) => {
		showAlert('Custom Error message: ' + err,'error');
		console.log(err); 
		}
		);
	}