vue-tweet-embed icon indicating copy to clipboard operation
vue-tweet-embed copied to clipboard

How do I put a variable in the <Tweet> id?

Open SalocinDotTEN opened this issue 6 years ago • 3 comments

My Tweet ID is pulled using the Buffer API and I would like to make it as the Tweet ID.

I have tried but it does not seem to work (or probably I am missing something. I am still quite new to Vue JS)..

Code: -

<template>
<div>
<Tweet :id="status" :options="{ theme: 'dark' }">
                <p>Loading...</p>
              </Tweet>
</div>
</template>

<script>
import { Tweet, Moment, Timeline } from "vue-tweet-embed";
import axios from "axios";

export default {
  components: {
    Tweet
  },
  data() {
    return {
      status: "",
    };
  },
  created() {
    axios
      .get(
        "..."
      )
      .then(response => {
        this.status = String(response.data.updates[0].service_update_id);
      })
      .catch(err => {
        console.log(err);
      });
  }
};
</script>

SalocinDotTEN avatar Apr 26 '19 16:04 SalocinDotTEN

Sorry. Following up, Tried a way that I thought would be successful but it turned out not to work still.

SalocinDotTEN avatar Apr 27 '19 15:04 SalocinDotTEN

@SalocinDotTEN I encountered a similar issue where I was dynamically changing the tweet ID, which would not update the component. I managed to get around the issue by setting a key on the Tweet component. This is admittedly a bit hacky, as it forces the component to re-render, however I think it is a suitable workaround for this issue right now.

<Tweet :id="status" :key="status" :options="{ theme: 'dark' }">
  <p>Loading...</p>
</Tweet>

brattonross avatar May 17 '19 10:05 brattonross

Thanks for the information. I may try it out although I am using a different method now.

SalocinDotTEN avatar May 24 '19 08:05 SalocinDotTEN