0
NativeScript 및 JSON에 조금 익숙하며 JSON 파일의 데이터에 액세스하는 데 약간의 문제가 있습니다. 지금은 일부 데이터 만 로그 아웃하려고합니다.JSON 데이터에 액세스하기 NativeScript
var config = require("../../shared/config");
var fetchModule = require("fetch");
var ObservableArray = require("data/observable-array").ObservableArray;
function StandingsListViewModel(items) {
var viewModel = new ObservableArray(items);
viewModel.load = function() {
var url = config.apiURI + "getStandings.cfm?weekid=397";
console.log(url);
return fetch(url)
.then(handleErrors)
.then(function(response) {
console.log(response.json());
return response.json();
})
.then(function(data) {
console.log("hit");
data.Result.forEach(function(standing) {
console.log(standing.place);
console.log(standing.username);
});
});
};
return viewModel;
}
function handleErrors(response) {
if (!response.ok) {
console.log(JSON.stringify(response));
throw Error(response.statusText);
}
return response;
}
module.exports = StandingsListViewModel;
내가 참조하고있어 JSON 파일 : 여기
내 뷰 - 모델에서 코드 나는이 아마 아주 기본적인 것을 알고{
"hiding": 0,
"lastupdate": 1474481622,
"refresh": 600,
"showmax": 0,
"showtie": 1,
"displayColumns" : [
"Points"
,"Wins"
,"TieDif"
],
"users" : [
{
"memberid" : 910089,
"username" : "THE DAILY ROUTINE",
"last_entry" : "1473446820",
"place" : "1",
"record" : [
"1.0"
,"1"
,"10.0"
]
} ,
{
"memberid" : 2234158,
"username" : "MR. MANAGER",
"last_entry" : "1473277680",
"place" : "2",
"record" : [
"1.0"
,"1"
,"26.0"
]
}
]
}
, 어떤 도움을 주시면 감사 .
이미 JSON 개체 (TypeError : 이미 읽음) 인 응답에서 .json()을 호출하는 오류가 발생한다는 것을 알았습니다. 응답을 많이 주셔서 감사합니다, 나는 확실히 그 console.dump()를 미래에 사용할 것이다. – SunnyBCC