tweetie icon indicating copy to clipboard operation
tweetie copied to clipboard

The only result is a for each error

Open retsoced opened this issue 6 years ago • 17 comments

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 } });

retsoced avatar Mar 28 '18 01:03 retsoced

same here

dgastudio avatar Jul 13 '18 09:07 dgastudio

Yup. I see the same error.

simonleadbetter avatar Jul 20 '18 14:07 simonleadbetter

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

sonnyt avatar Jul 20 '18 14:07 sonnyt

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.

simonleadbetter avatar Jul 20 '18 14:07 simonleadbetter

@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.

sonnyt avatar Jul 20 '18 14:07 sonnyt

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.

simonleadbetter avatar Jul 20 '18 14:07 simonleadbetter

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 avatar Sep 22 '18 20:09 robwent

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 avatar Sep 22 '18 20:09 robwent

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 avatar Sep 24 '18 12:09 robwent

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.

robwent avatar Sep 24 '18 14:09 robwent

@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?

sonnyt avatar Sep 24 '18 14:09 sonnyt

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 avatar Sep 24 '18 14:09 robwent

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

robwent avatar Sep 24 '18 15:09 robwent

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

sonnyt avatar Sep 24 '18 15:09 sonnyt

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.

robwent avatar Sep 24 '18 15:09 robwent

Any solution? I have same issue.

bilalmalkoc avatar May 23 '19 10:05 bilalmalkoc

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

BN83 avatar Mar 26 '20 14:03 BN83