I have a strange problem with the AJAX request to the remote server. If I make a request through POSTMAN, then I get a response with a nested array.
{
"id": "n254",
"created": "2017-10-02T11:50:29+0200",
"modified": "2017-10-09T14:19:15+0200",
"status": true,
"town_id": 16,
"image": "pic.jpg",
"image_dir": "img",
"wp_id": "5312",
"newsdescriptions": [
{
"id": 419,
"name": "Name",
"description_short": "Description short",
"description_long": "<p>Description long</p>",
"new_id": 254,
"language_id": 2,
"created": "2017-10-02T11:50:29+0200",
"modified": "2017-10-05T12:07:04+0200"
}
],
"type": "new",
"image_url": "https://192.168.1.102/img/news/image/pic.jpg"
}
But if I make a request from an application, I get a response from the application without a nested array.
{
"id": "n254",
"created": "2017-10-02T11:50:29+0200",
"modified": "2017-10-09T14:19:15+0200",
"status": true,
"town_id": 16,
"image": "pic.jpg",
"image_dir": "img",
"wp_id": "5312",
"newsdescriptions": [],
"type": "new",
"image_url": "https://192.168.1.102/img/news/image/pic.jpg"
}
The code that makes the request:
$http({
url: ApiEndpoint.url + '/news/selectNew/' + params.townhallId + '/' + params.langId + '/' + params.id,
method: 'GET',
cache: false,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'User': 'user',
'Password': 'pass'
}
}).then( function(data) {
console.log("URL Ajax:");
console.log(ApiEndpoint.url + '/news/selectNew/' + params.townId + '/' + params.langId + '/' + params.id);
console.log("Data:");
console.log(data.data);
callback(data.data);
}, function(data) {
console.log('getNew: ajax error!');
});
Help please solve this problem!