Programming/web 관련
ajax bearer token header
구차니
2019. 2. 7. 18:15
ajax 에 authorization bearer 추가하는 방법
// ajax
$.ajax({
url: 'YourRestEndPoint',
headers: {
'Authorization': `Bearer ${token}`,
},
method: 'POST',
data: YourData,
success: function(data){
console.log('succes: '+data);
}
});
// axios
axios({
method: 'post',
url: yourEndpoint,
data: yourData,
headers: { 'authorization': `Bearer ${token}` } }); |
[링크 : https://www.freecodecamp.org/.../which-ajax-should-i-use-for-post-i-need-to-add-a-bearer-token/.../2]