Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The only result is a for each error #93

Open
retsoced opened this issue Mar 28, 2018 · 17 comments
Open

The only result is a for each error #93

retsoced opened this issue Mar 28, 2018 · 17 comments

Comments

@retsoced
Copy link

No matter what the settings, the function only returns an error:
TypeError: e.forEach is not a function

I assume this is returning no results, but everything seems to be set correctly.
$('.tweetfeed').tweetie({ "url": "/api/", "type": "timeline", "template": "<li>{{tweet.created_at}} - {{tweet.text}}</li>", "dateFormat": "%b %d, %Y", "params": { "count": 15 } });

@dgastudio
Copy link

same here

@simonleadbetter
Copy link

Yup. I see the same error.

@sonnyt
Copy link
Owner

sonnyt commented Jul 20, 2018

That is strange, do you have an endpoint I can try out?
Also, which API you guys are using?

@simonleadbetter
Copy link

simonleadbetter commented Jul 20, 2018

PHP. Unfortunately, I can not share the endpoint on this post due to client confidentiality.

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="/dist/tweetie/dist/tweetie.min.js"></script>

  {# {% do view.registerJsFile("/dist/tweetie/dist/tweetie.min.js") %} #}

  <script type="text/javascript">
    $('#tweets').tweetie({
      url: '/dist/tweetie/api/php/tweetie.php',
      type: 'timeline',
      template: '<li>{% verbatim %}{{tweet.created_at}}{% endverbatim %} - {% verbatim %}{{tweet.text}}{% endverbatim %}</li>',
      dateFormat: '%b %d, %Y',
      params: {
        count: 15,
        screen_name: null,
        exclude_replies: false,
        include_rts: false
      }
    });
</script>

The {% verbatim %} tags are there to stop a clash with Craft CMS.

In case it is useful, I have downloaded the files via bower.

@sonnyt
Copy link
Owner

sonnyt commented Jul 20, 2018

@simonleadbetter is your PHP file hosted somewhere on a server? Like can you call that page via postman or browser directly? Just curious if it's returning any response.

@simonleadbetter
Copy link

It is, but I can not publish the URL as the site is in development. Is there a way I can share the URL with you so it is not public?

The tweetie.php file is executing on the server.

@robwent
Copy link

robwent commented Sep 22, 2018

I'm getting the same thing using the timeline endpoint.

This is the response from twitter:
https://gist.github.com/robwent/738cb69ae000619995b4e92d65b6eb86

Browser console error:

   tweetie.min.js:1 Uncaught TypeError: e.forEach is not a function
    at Object.<anonymous> (tweetie.min.js:1)
    at fire (jquery.js?0edfd041b07867c9ed3ac92157993e2a:3232)
    at Object.fireWith [as resolveWith] (jquery.js?0edfd041b07867c9ed3ac92157993e2a:3362)
    at done (jquery.js?0edfd041b07867c9ed3ac92157993e2a:9840)
    at XMLHttpRequest.callback (jquery.js?0edfd041b07867c9ed3ac92157993e2a:10311)

Same thing testing with other endpoints.

The username I'm searching for is also being ignore and the response is for the user that created the twitter app to get the keys.

@robwent
Copy link

robwent commented Sep 22, 2018

I fixed my issue with the username. The params were getting lost.

I now get the tweets from the user, but the foreach error is still the same.

New response: https://gist.github.com/robwent/1b460cf4a96cf43e1e34428cb4390057

@robwent
Copy link

robwent commented Sep 24, 2018

I've uploaded to a demo site if that's any easier: https://ovrr.to/Lc6Lq The tweets should show next to the news section.

I've tried different versions of jQuery but got the same result with all of them.

@robwent
Copy link

robwent commented Sep 24, 2018

There are 2 tweetie.min.js files in the dist folder.

The first one is the one that causes the foreach error.

The secodnd one in dist/dist that gets built by webpack shows:

Uncaught TypeError: Cannot read property 'errors' of undefined
    at Object.<anonymous> (tweetie.min.js:1)
    at i (jquery.min.js?237c0a7d609dc2e7cae6d026920286c2:2)
    at Object.fireWith [as rejectWith] (jquery.min.js?237c0a7d609dc2e7cae6d026920286c2:2)
    at y (jquery.min.js?237c0a7d609dc2e7cae6d026920286c2:4)
    at XMLHttpRequest.c (jquery.min.js?237c0a7d609dc2e7cae6d026920286c2:4)

I got rid of the foreach error using this: https://stackoverflow.com/a/35970005/931438

But then I got other errors related to the month strings.

Makes me wonder if it's the es version bable is compiling to, but for now, I've gone back to 2.4.3 and got that working with the server version from 3.

@sonnyt
Copy link
Owner

sonnyt commented Sep 24, 2018

@robwent I just checked out your website, it looks like the index.php?option=com_ajax&module=etsi_twitter&format=raw endpoint is returning using the text/html content type, can you try changing that to application/json?

@robwent
Copy link

robwent commented Sep 24, 2018

oh la la, I didn't think about that.

I just got it working with a mixture of the old/new versions, but I'll test that out and let you know.

@robwent
Copy link

robwent commented Sep 24, 2018

I still get the same when the response is returned with the header: Content-Type: application/json; charset=utf-8

@sonnyt
Copy link
Owner

sonnyt commented Sep 24, 2018

@robwent that is strange, do you have link I can check out?

@robwent
Copy link

robwent commented Sep 24, 2018

Not live, but it will return the json header by changing the url to index.php?option=com_ajax&module=etsi_twitter&format=json

So I put the latest js version back and changed the js to use the settings params array and got the same foreach error.

I'll try it out again later as I'd like to use more than the old templating placeholders.

@bilalmalkoc
Copy link

Any solution? I have same issue.

@BN83
Copy link

BN83 commented Mar 26, 2020

I've got the same issue too. Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants