deleteRecipe

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

構文 

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

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

DELETE /wave/recipes/${id}

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

パラメータ 

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

戻り値 

戻り値の型は void です。

使用方法 

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

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

import { LightningElement, api } from "lwc";
import { deleteRecipe } from "lightning/analyticsWaveApi";
import { ShowToastEvent } from "lightning/platformShowToastEvent";

export default class DeleteRecipe extends LightningElement {
  @api id; // or fetch the ID

  delete(event) {
    deleteRecipe({ id: this.id })
      .then(() => {
        this.dispatchEvent(
          new ShowToastEvent({
            title: "Success",
            message: "Recipe Deleted",
            variant: "success",
          }),
        );
      })
      .catch((error) => {
        this.dispatchEvent(
          new ShowToastEvent({
            title: "Error deleting recipe",
            message: error.body.message,
            variant: "error",
          }),
        );
      });
  }
}

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

<template>
  <lightning-button
    label="Delete"
    icon-name="utility:delete"
    icon-position="right"
    onclick={delete}
  >
  </lightning-button>
</template>

The Japanese Summer '24 guide is now live

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