WizardFactory / BlogSyncer

one write posting all of the world
Apache License 2.0
3 stars 10 forks source link

tistory에 블로그가 하나밖에 없을 경우 정상적으로 블로그를 가져오지 못하는 오류 #347

Closed neoqmin closed 8 years ago

neoqmin commented 8 years ago
tistory에 블로그가 하나밖에 없을 경우 아래의 코드에서 오류가 발생합니다.

tistory.js(ln:182)

var item = JSON.parse(body).tistory.item;
// 블로그가 하나일 경우 item.length가 undefined입니다.
log.debug('item length=' + item.length, meta);
// 아래에서 botBlogList에 botBlog를 추가히지 못합니다.
for (var i = 0; i < item.length; i+=1) {

    {생략}

    var botBlog = new botFormat.BotBlog(target_url, item[i].title, item[i].url);
    botBlogList.blogs.push(botBlog);
}
kimalec commented 8 years ago

아 tistory에서는 object가 여러개면 arrary로 보내고, 하나면 array 만들지 않고 바로 object 실어서 그런거 같아

neoqmin commented 8 years ago
네 맞습니다.

그래서 item.length가 undefined일 경우 item[0]에 JSON.parse(body).tistory.item를 대입하는 방법을 사용할까합니다.