用ajax Jquery调用API

i have request

$(function(){
    $.ajax({
        type: 'GET',
        dataType:"jsonp",
        url: "http://localhost:8000/api/admin/announces",       
        headers:{         
            'Authorization' : 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBWZXIiOiIwLjAuMCIsImV4cCI6NDcyNjM4OTEyMiwibG9jYWxlIjoiIiwibWFzdGVyVmVyIjoiIiwicGxhdGZvcm0iOiIiLCJwbGF0Zm9ybVZlciI6IiIsInVzZXJJZCI6IiJ9.QIZbmB5_9Xlap_gDhjETfMI6EAmR15yBtIQkWFWJkrg',
            'Content-Type':'application/json'
        },
        succces: function(data){
            console.log('success',data);                    
        }
    });
});

and i having 400 bad request error net::ERR_ABORTED 400 (Bad Request). What am I missing ?

When a server cannot understand a request, its called 400 error. There are few reason for it. Maybe you have used a url with invalid token or cookie. Please make sure ur bearer token is valid.. Clear ur DNS cache, browser cache..i think its your bearer token.. Please make sure your bearer token is valid..

You just need to replace URL with your local REST API:

$.ajax({
  type: 'GET',
    dataType:"jsonp",
  url: 'https://jsonplaceholder.typicode.com/todos/1',
  headers:{         
      'Authorization' : 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBWZXIiOiIwLjAuMCIsImV4cCI6NDcyNjM4OTEyMiwibG9jYWxlIjoiIiwibWFzdGVyVmVyIjoiIiwicGxhdGZvcm0iOiIiLCJwbGF0Zm9ybVZlciI6IiIsInVzZXJJZCI6IiJ9.QIZbmB5_9Xlap_gDhjETfMI6EAmR15yBtIQkWFWJkrg',
      
  },
  success: function (data, status, xhr) {
    console.log('data: ', data);
  }
});

</div>