0
API에서 데이터를 가져 오려고합니다. 내가 얻는 건 204 상태 야. DB에 데이터가 있는데 POSTMAN에서 호출하면 적절한 데이터가 전송됩니다. 여기 API 호출이 데이터를 반환하지 않습니다. http.get()
는collections.ts
입니다 : 여기
ngOnInit() {
console.log("this is collections page")
this.loanService.getCollectionList().subscribe(response => {
this.collections = response;
})
console.log(this.collections)
}
이 내 길이다
public getCollectionList(){
const path = this.basePath + '/collections'; // change the path
let queryParameters = new URLSearchParams();
let headerParams = this.defaultHeaders;
// queryParameters.set('','');
let requestOptions: RequestOptionsArgs = {
method: 'GET',
headers: headerParams
// search: queryParameters
};
return this.http.request(path, requestOptions)
.map((response: Response)=> {
if (response.status === 204) {
return undefined;
} else {
return response.json();
}
});
}
내 loanService입니다 - collection.js
:
router.get('/collections', function (req, res, next) {
// var errors = req.validationErrors();
if (errors) {
console.log('Errors');
res.status(400);
res.json(errors);
} else {
console.log(req.query);
// db.loans.find({ 'STATE' : state, 'LOAN_BRANCH' : loanBranch }, function(err, loans){
db.collections.find(req.query, function (err, collections) {
if (err) {
res.status(400);
res.send(err);
} else {
// console.log(collections);
res.json(collections);
}
})
}
});
확인 .... 그래서 난 템플릿에 이제 데이터를 사용할 수 있습니다 (collections.html) 직접 :
는 모습이 위대한 게시물을 가져? –@hemanthkoganti는 사용 방법에 따라 다릅니다. 귀하의 질문에 HTML을 포함하십시오. – echonax
네, 그럴 수있어 ........ thanks @echonax –