我使用yeoman angular-fullstack生成我的項目。 所以客戶端是angularJs(typeScript),後端是nodeJs。 問題是我有一個變量,當我打印到控制檯時,我得到一個很長的字符串,(如果你需要知道它從googleplacesapi的photo_reference)。 當我將它傳遞給帶有http.get的nodeJS api,並將其打印到日誌中時,我得到響應Object對象。從客戶端傳遞到nodeJS時,字符串轉向對象
MainController
for (var photo of response.data.result.photos) {
this.getImages(photo);
console.log(photo.photo_reference);
}
getImages(photo_reference: string): void{
this.$http.get('/api/image/' + photo_reference).then((response) => {
});
}
的NodeJS
export function show(req, res) {
console.log("photoreference:" + req.params.photoreference);
@mmm好像打字稿 – eltonkamami
出於好奇(不是溶液) ,如果你顯式轉換爲字符串,它是否工作? – ale10ander
記錄參數,而不將它連接到一個字符串以查看傳入的值'console.log(req.params.photoreference);' – eltonkamami