2017-01-19 12 views
-4

github apiを使用してreposのリストを表示する必要があるウェブページに取り組んでいます。しかし、401エラーを取得してください。私が間違っていた場所がわからない.....ここに は、私がこれまで持っているものです。jquery Github api

function requestJSON(url, callback) { 
$.ajax({ 
    url: url, 
    dataType: "json", 
    complete: function(xhr) { 
    callback.call(null, xhr.responseJSON); 
    console.log(xhr.responseJSON); 
    //alert('Load was performed.'); 
    if (xhr.status === 200) { 
    alert('User\'s name is ' + xhr.responseText); 
} 
else { 
    alert('Request failed. Returned status of ' + xhr.status); 
} 
    }, 
    error: function(req, status, err) { console.log('something went wrong', status, err); 
}, 
    beforeSend: function(xhr, settings) { xhr.setRequestHeader('Authorization',authCredentials); 
     xhr.setRequestHeader('Content-Type', 'text/plain');} 
}); 
} 
}); 

答えて

0
beforeSend: function(xhr, settings) { xhr.setRequestHeader('Authorization',authCredentials); 
    xhr.setRequestHeader('Content-Type', 'text/plain');} 

それは私のauthCredentialsの問題、ミスタイプ.....

ました