Streaming live at 10am (PST)

Help getting sites/collections/items/Fields data


#1

Hello,
I tried to get my site in order to get the inputs of my fields however it doesn’t seem to be working.

The main idea of what I want to do eventually is to make it so onclick of a media item, the main video iframe changes it’s link to the relevant item.
The entire youtube link is saved in a collection list called media under Media Link or Video Link (They have the same links)

Here is my code so far that returns nothing and doesn’t create an alert box even, if someone would be kind enough to point me in the right direction that would be amazing!

const webflow = new Webflow({ token: '82727037e43cb652270a3871ac0647d89081a7f52182e34a74bacc19c9b511e2' });

// Promise <[ Site ]>
const sites = webflow.sites();

sites.then(s => window.alert(s));
alert("peepee");

Here is a link to my site:

https://preview.webflow.com/preview/david-dor?preview=21045df93b4b9d534260a418cb68662b

Thank you in advance!


#2

Site is unpublished. I also can’t find where you are using the above code in your site.

I don’t think the API is meant to be “initialized” this way.


Side note, you shouldn’t be using API keys in JS, as anyone can “steal” them and make modifications to your site using that key.

You also shouldn’t be posting the key in the forum (although I have verified that the key works and I can retrieve your site).

Example of a single item in your media collection:

{
  "items": [
    {
      "_archived": false,
      "_draft": false,
      "category": "6d6a83f68ba2094312adcbc8568da3c7",
      "video-link": "https://www.youtube.com/embed/BBrM_QoaoCI",
      "name": "Yashar El",
      "media-image": {
        "fileId": "594ae7f63ca9026bddba3d79",
        "url": "https://daks2k3a4ib2z.cloudfront.net/5843d31bcc7df28a6b84501d/5941a8f1fc58774c4374f8fc_Yashar%20el.png"
      },
      "slug": "yashar-el",
      "updated-on": "2017-06-28T13:20:27.045Z",
      "updated-by": "Person_5843d27a6f48a0766b95d64e",
      "created-on": "2017-06-12T20:23:05.680Z",
      "created-by": "Collaborator_593d959ee5608a435f48f80c",
      "published-on": "2017-06-28T13:20:33.488Z",
      "published-by": "Person_5843d27a6f48a0766b95d64e",
      "media-video": {
        "url": "https://www.youtube.com/embed/BBrM_QoaoCI",
        "metadata": {
          "width": 250,
          "height": 141,
          "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FBBrM_QoaoCI%3Ffeature%3Doembed&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBBrM_QoaoCI&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FBBrM_QoaoCI%2Fhqdefault.jpg&key=96f1f04c5f4143bcb0f2e68c87d65feb&type=text%2Fhtml&schema=youtube\" width=\"250\" height=\"141\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>",
          "aspectRatio": 1.7730496453900708,
          "title": "דוד ד׳אור - ישר אל (עם מילים)",
          "provider_name": "YouTube",
          "type": "video",
          "description": "Join David D'or on facebook here: הצטרפו לעמוד הרשמי של דוד בפייסבוק כאן: https://www.facebook.com/daviddor.official Subscribe to David's main Youtube Channel: הצטרפו לערוץ הראשי של דוד ביוטיוב על ידי לחיצה כאן: http://smarturl.it/YouTubeJoinDavidDor Buy David's Music on Loudr (better prices) : http://ldr.fm/a/DhyBP The whole Discography available on iTunes: http://smarturl.it/iTunesDavidDor מילים: ---------- מזמן",
          "author_name": "David Deor"
        }
      },
      "_cid": "594ae7f63ca9026bddba3a8d",
      "_id": "594ae7f63ca9026bddba3cf0"
    }
  ],
  "count": 1,
  "limit": 100,
  "offset": 0,
  "total": 58
}