deleteRecipe

特定のデータプレップレシピを ID で削除します。

構文 

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

データプレップレシピ API リソース 

1DELETE /wave/recipes/${id}

deleteRecipe は、このデータプレップレシピ API リソースを使用します。

パラメータ 

  • id — (必須) データプレップレシピの ID。

戻り値 

戻り値の型は void です。

使用方法 

deleteRecipe を使用するには、いくつかの方法があります。たとえば、レシピのリストを表示し、リストの各レシピに対して削除を行うことができます。

次の例では、レシピが含まれるページに削除ボタンを追加します。レシピを削除すると、lightning/platformShowToastEvent モジュールを使用して、トーストメッセージが表示されます。

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}

このボタンは、deleteRecipe() メソッドをコールします。

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>

The Japanese Summer '24 guide is now live

日本語の Summer '24 ガイドが公開されました! 「Component Reference (コンポーネントリファレンス)」は、以前と同様にコンポーネントライブラリにあります。