0
Instagram API를 사용하여 웹 앱을 만들었습니다. 내 'server.js'파일, 내 노드 서버의 주 파일에 아래 코드가 있습니다. 문제는 '텍스트'값이 종종 'null'(Instagram 사용자가 이미지를 캡션하지 않을 때마다)이라는 것입니다. 이 null 값은 내 응용 프로그램을 충돌시킵니다. 이 상황을 설명하기 위해이 코드를 어떻게 향상시킬 수 있습니까? 제 생각은 'text'가 null 일 때마다 삽입되는 'text'의 기본값을 제공하는 것입니다.null 값이 전달되면 Heroku 앱이 충돌합니다.
//Save the new object to DB
Stadium.findOneAndUpdate({object_id: data.object_id}, { $push: {'photos':
{ img: image.data[0].images.standard_resolution.url,
link: image.data[0].link,
username: image.data[0].user.username,
profile: image.data[0].user.profile_picture,
text: image.data[0].caption.text
}}},
{ safe: true, upsert: false },
function(err, model) {
console.log(err);
}
);
//Send a socket to client with the new image
newImage({
img: image.data[0].images.standard_resolution.url,
link: image.data[0].link,
username: image.data[0].user.username,
profile: image.data[0].user.profile_picture,
text: image.data[0].caption.text
});