0

I am trying below code to delete item using spfx it also goes in success and give me alert but its not deleting item at backend in table

Does any one have idea what i am doing wrong in this code to delete item

deleteitem = (item: ISuggestionItem) => {
   this.props.context.aadHttpClientFactory
   .getClient('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
   .then((client: AadHttpClient): void => {
     
     client
       .fetch('https://xxxx.xxxx.net/api/xxxxx', AadHttpClient.configurations.v1,{
         method: 'DELETE',
         headers: {
             'Content-Type': 'application/json'
         },

         body: JSON.stringify({
          xxxxxx: this.props.context.pageContext.user.email,
          key: item.key,
          test: item.test
          
        })
        
        })
        
        .then((response: HttpClientResponse) => {
         if (response.ok) {
             alert(`Item delete successfully with ID: ${item.key}`);
          
        } else {
          
             alert(`Something went wrong! Check the error in the browser console.`);
        
        }
      }).catch(error => {
        console.log(error);
     });
   
     }); 
    }
Ashok
  • 59
  • 1
  • 10

0 Answers0