문제

I have this code:

 $ = $root.cheerio.load(body)
 results = $('#selector').map (index, element)->
      items = []
      $(this).find('.item_link').each (i, el)->
        console.log("asdf")
        items[i] =  $(this).attr('title')

      result=
        name: $(this).find('.the_name_link').attr('title') 
        #HERE I'd like to do something with items but it's not working
      return result

    return callback(null,results)

So when this code is executed, there's basically no error, and in my interface I get a result with

[
    {
        "name": "The Name I was looking for"
        }
]

But it seems the code in the each block never gets executed (there's no console output 'asdf'). What am I doing wrong?

도움이 되었습니까?

해결책

Now this has been seriously ill-leading. Problem was a wrong parameter sent to the app which would reply with incomplete html, thus the code was (correctly...) not finding the divs I was looking for :)

Thus the coffeescript above is correct.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top