I have an API managed with Laurvel, Dingo and JWT Tokens. Testing an API call using PAW works great. Making API calls using jQuery without middleware. Disabling JWT Tokens works great. But as soon as I try to start an Ajax request with JWT tokens, I get 401.
I miss the trick with the Ajax request. Do you see a problem with this code?
$.ajax({ url: "http://api.domain.app/products", dataType : 'jsonp', type: 'GET', beforeSend : function(xhr) { xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.setRequestHeader("Authorization", "Bearer XXXX"); }, error : function() {
I need to use jsonp due to Cross Domain. But then again, this works great with JWT middleware.
I hope you can advise ..
source share