Skip to main content
1

Creating a deleteDestination function

In your frontend, call the useDeleteDestination hook to generate a function that fetches a scoped auth token and uses it to delete the destination scoped by the token. Use one of the fetchToken functions you wrote in Building an “Add Destination” connection form here to create one.
Create deleteDestination
const deleteDestination = useDeleteDestination(
  fetchToken,  				// fetchToken implementation, takes an ExistingDestination
  "app.example.co", 	// the origin of your React app (used to allow CORS),
  PREQUEL_HOST 				// Optional (default api.prequel.co): the host url of your Prequel API
);
2

Using deleteDestination

Use deleteDestination created in Step 1 to delete the given destination.
DestinationView
const DestinationView = () => {
  // Deletion function creation elided

	// Async function deletes destination using Prequel API
	async function onDelete(existing: ExistingDestination) => {
  	const response = await deleteDestination(existing);
		if (response.status === "success") {
	  	// Handle success
  	} else {
	  	// Handle failure
  	}
	};

  return (
		<button type="button" onClick={onDelete}>Delete destination</button>
  );
}