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

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

Open
SalocinDotTEN opened this issue Apr 26, 2019 · 3 comments
Open

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

SalocinDotTEN opened this issue Apr 26, 2019 · 3 comments

Comments

@SalocinDotTEN
Copy link

SalocinDotTEN commented Apr 26, 2019

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
Copy link
Author

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

@brattonross
Copy link
Contributor

brattonross commented May 17, 2019

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

@SalocinDotTEN
Copy link
Author

SalocinDotTEN commented May 24, 2019

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

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

2 participants