Answer the question
In order to leave comments, you need to log in
How to send and receive JSON data correctly?
Good afternoon dear experts. Faced the following problem:
On the server side, I form a json object as follows:
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
header("Content-Type: application/json;charset=utf-8");
fetchData: function () {
this.$http.get(this.apiURL).then(function (response) {
console.log(response);
this.items = response.data;
}, function (error) {
//error
})
}
Answer the question
In order to leave comments, you need to log in
this.$http.get(this.apiURL)
.then(function (response) {
return response.json();
})
.then(function(obj) {
console.log(obj.data)
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question