Answer the question
In order to leave comments, you need to log in
Crooked JSON response?
I am writing an application in react-native and ran into the following problem:
It is required to display the schedule by specifying the route for the train.
Here is a piece of code that I use to call the js script (it will be below) in order to pull out the schedule itself by the name of the stations.
api(froms).then(
(data) => {
if(data.doc){
var value = this.state.dataSource.cloneWithRows(data.doc.value);
this.setState({
hasResult: true,
noResult: false,
result: data.doc,
value: value,
isLoading: false
});
var type_names = _.map(data.doc.value, function(type){
return type.value;
});
}else{
this.setState({
hasResult: false,
noResult: true,
isLoading: false,
result: null
});
}
}
);
module.exports = function(froms){
var url = 'http://awgfawfwafawf.awfa/train/get.php?from=' + froms;
return fetch(url).then(function(response){
return response.json();
}).then(function(json){
return json;
});
}
{"id":"2cc939baf01d563ff36bc878a217feea",
"key":"Подлипки-Дачные",
"value":"Москва (Ярославский вокзал) — Монино",
"doc":{"_id":"2cc939baf01d563ff36bc878a217feea","_rev":"1-9aac915114795ba2ca720bbba8bbd201",
"title":"Москва (Ярославский вокзал) — Монино","from":"Подлипки-Дачные",
"to":"Монино","departure":"2017-05-23 00:47:00","arrival":"2017-05-23 01:28:00","stops":"везде"}}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question