deleteRecipe

Deletes a specific data prep recipe by ID.

Syntax 

1import { deleteRecipe } from 'lightning/analyticsWaveApi';
2deleteRecipe({ id: string }): Promise<void>

Data Prep Recipe API Resource 

1DELETE /wave/recipes/${id}

deleteRecipe uses this Data Prep Recipe API resource.

Parameters 

Parameter NameTypeDescriptionRequired?
idStringThe ID of the data prep recipe.Yes

Returns 

The return type is void.

Usage 

There are several ways to use deleteRecipe. For example, you can display a list of recipes and enable delete on each recipe on the list.

This example adds a delete button to a page with recipes. Deleting a recipe displays a toast message using the lightning/platformShowToastEvent module.

1import { LightningElement, api } from "lwc";
2import { deleteRecipe } from "lightning/analyticsWaveApi";
3import { ShowToastEvent } from "lightning/platformShowToastEvent";
4
5export default class DeleteRecipe extends LightningElement {
6  @api id; // or fetch the ID
7
8  delete(event) {
9    deleteRecipe({ id: this.id })
10      .then(() => {
11        this.dispatchEvent(
12          new ShowToastEvent({
13            title: "Success",
14            message: "Recipe Deleted",
15            variant: "success",
16          }),
17        );
18      })
19      .catch((error) => {
20        this.dispatchEvent(
21          new ShowToastEvent({
22            title: "Error deleting recipe",
23            message: error.body.message,
24            variant: "error",
25          }),
26        );
27      });
28  }
29}

This button calls the deleteRecipe() method.

1<template>
2  <lightning-button
3    label="Delete"
4    icon-name="utility:delete"
5    icon-position="right"
6    onclick={delete}
7  >
8  </lightning-button>
9</template>