Guest User

Untitled

a guest
Apr 4th, 2022
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2.  
  3. const RemoveItem = (props) => {
  4.  
  5.     let handleDeleteItem = async () => {
  6.  
  7.       if (window.confirm(`Czy na pewno usunąć: ${props.name} ?`) == true) {
  8.  
  9.         let response = await fetch(`${props.url}`, {
  10.           method: "DELETE",
  11.           headers: {
  12.             "Content-Type":"application/json",
  13.             "Authorization": "Bearer " + String(authTokens.access)
  14.           }
  15.         })
  16.  
  17.         if(props.refreshList != false){
  18.           props.refreshList();
  19.         }
  20.       }
  21.     }
  22.  
  23.   return (
  24.         <button onClick={()=>handleDeleteItem()}>usuń</button>
  25.   )
  26. }
  27.  
  28. export default RemoveItem
Advertisement
Add Comment
Please, Sign In to add comment