与REST API的连接失败

have a problem when i am trying to connect and do a really sample GET request on a REST API.

Here is my code:

 $.ajax({
 url : 'https://recruitment.elements.nl:8080/v1/carousel/',
 type : "GET",
 dataType: "json",
 data : { token : '733129ed5566ed9b030872c6e003155a82da3c55' },
 success : function(data) { 
    alert('data');
 },
 error : function(xhr) { }
});

My problem is, this is returning a 401 error when i am trying to connect to the API on my JS but it's working when i am doing it directly on the website. So I think there is a bug with my data token line.

Any ideas why ?

Thanks a lot for taking time to answer me.

Rayden

I think there is problem with header Token modify it accordingly. I tried with curl by sending it in header. add this custom header

curl -X GET https://recruitment.elements.nl:8080/v1/carousel/ -H 'Authorization: Token 733129ed5566ed9b030872c6e003155a82da3c55'

This works for me.

{
"count": 3,
"next": null,
"previous": null,
"results": [
    {
        "id": 1,
        "image": "https://recruitment.elements.nl:8080/media/carousel/caroussel_1.png",
        "image_2x": "https://recruitment.elements.nl:8080/media/carousel/caroussel_12x.png",
        "title": "Little tittle",
        "subtitle": "Big Title",
        "action": "Button Action",
        "action_url": "https://www.elements.nl/portfolio/mcdonalds-picto-campaign/"
    },
    {
        "id": 2,
        "image": "https://recruitment.elements.nl:8080/media/carousel/caroussel_2.png",
        "image_2x": "https://recruitment.elements.nl:8080/media/carousel/caroussel_22x.png",
        "title": "NU.nl responsive website",
        "subtitle": "NEW WEBSITE",
        "action": "GO!",
        "action_url": "https://www.elements.nl/portfolio/nu-nl-responsive-website/"
    },
    {
        "id": 3,
        "image": "https://recruitment.elements.nl:8080/media/carousel/caroussel_3.png",
        "image_2x": "https://recruitment.elements.nl:8080/media/carousel/caroussel_32x.png",
        "title": "don't text and cycle",
        "subtitle": "Fietsmodus app",
        "action": "go to project",
        "action_url": "https://www.elements.nl/portfolio/fietsmodus/"
    }
]

}

$.ajax({
url: 'YourRestEndPoint',
headers: {
    'Authorization':'Token xxxxxxxxxxxxx'
},
method: 'GET',
dataType: 'json',
data: YourData,
success: function(data){
  console.log('succes: '+data);
}

});