How to include header in ajax request?

前端 未结 3 1553
情话喂你
情话喂你 2021-01-24 18:37

I need to include a header with a refresh token in an ajax call to the YouTube api. I am trying to send a delete request, to delete a movie I have on my account. This is my ajax

3条回答
  •  星月不相逢
    2021-01-24 19:02

    Try add the paramenter data.

    jQuery.ajax({
        type: 'DELETE',
        data: 'key=' + {YOUR_API_KEY},
        // must set api key
        url: 'https://www.googleapis.com/youtube/v3/videos?id='+ thisUniqueID + '&key=904907387177-qe517sq5dmmpebckjbmrhv4gvac9e2d1.apps.googleusercontent.com',
        success: function() {
        alert('your video has been deleted');
        },
        error: function() {
        alert('error processing your requst');
        }
    });
    

提交回复
热议问题