Search code examples
jqueryrestcurlsuperagent

Using curl to make ajax call


curl -X DELETE https://www.filestackapi.com/api/file/**HANDLE**?key=APIKEY

I want to use the above curl call to delete a file from filestack storage. How can I use that in an ajax call either using jQuery or SuperAgent?


Solution

  • With jQuery:

    $.ajax({
        url: 'https://www.filestackapi.com/api/file/HANDLE?key=APIKEY',
        type: 'DELETE',
        success: function(result) {
            // Do something with the result
        }
    });
    

    With superagent

    request
      .del('https://www.filestackapi.com/api/file/HANDLE?key=APIKEY')
      .end(function(err, res){
    
      });