csdn产品小助手 2019-11-25 08:55 采纳率: 0%
浏览 94

用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 ?

  • 写回答

2条回答 默认 最新

  • George_Fal 2019-11-25 09:35
    关注

    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..

    评论

报告相同问题?