Answer the question
In order to leave comments, you need to log in
Why am I getting 401 errors when making a fetch request?
I'm starting to learn Vue JS, as well as modern JavaScript features.
Client code:
var app = new Vue({
el: '#ex-ways',
data: {
giveBanks: [],
receiveBanks: [],
},
created: function() {
this.getGiveBanks()
},
methods: {
getGiveBanks: function(){
var self = this;
fetch('/front/get_give_banks', {
method: 'get',
headers: {
'Content-Type': 'application/json',
}
}).then(function(response){
if (response.status == 200) {
console.log('success');
} else {
console.log(response);
}
});
}
}
});
public function get_give_banks()
{
$banks = $this->db->where('give_money', 1)->get('banks')->result_array();
echo json_encode($banks, JSON_UNESCAPED_UNICODE);
}
Answer the question
In order to leave comments, you need to log in
I think that this problem does not concern vue, looking at the server side.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question