Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

undefined method `each' for nil:NilClass when iterating over empty response #6

Open
aleccarper opened this issue Sep 23, 2016 · 1 comment

Comments

@aleccarper
Copy link

Hello,

I've recently encountered an error that occurs while trying to iterate over orders, or simply checking the count of orders, when no orders are returned. I have tracked this down to line 39-41 of paged_ecwid_response.rb:

    response.body["items"].each do |item|
      yielder << block.call(item)
    end

If this block is moved below where count, offset, and total are set and then wrapped in an if count > 0 both iteration and count checks work as expected.

@davidbiehl
Copy link
Owner

cool, good find. i'd be happy to accept a PR from you with the fix!

Nkadze added a commit to Nkadze/ecwid_api that referenced this issue Aug 4, 2018
Made this changes, as @aleccarper suggested [here](davidbiehl#6 (comment))
I was encountering those issue quite often while using this gem on my production app, @davidbiehl also asked for pull request, so I made it
@Nkadze Nkadze mentioned this issue Aug 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants