Guest User

Untitled

a guest
Jan 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <script>
  2. import db from '../firebaseInit'
  3.  
  4. export default {
  5. name: 'search-result',
  6. props: {
  7. resultID: {
  8. type: String,
  9. required: true,
  10. },
  11. },
  12. data () {
  13. return {
  14. id : this.resultID,
  15. data: {
  16. id: '',
  17. movies: {
  18. poster: '',
  19. name: '',
  20. director: '',
  21. stars: '',
  22. genre: '',
  23. metascore: null
  24. }
  25. }
  26. }
  27. },
  28. methods: {
  29. getData(data) {
  30. const movieRefs = db.collection('movies').doc(this.id)
  31. const searchResult = movieRefs.get()
  32. .then(doc => {
  33. const data = {
  34. movies: doc.data(),
  35. id: this.id
  36. }
  37. return this.data = data
  38. })
  39. .catch(function(error) {
  40. console.log("Error getting document:", error);
  41. });
  42. },
  43. },
  44. mounted() {
  45. this.getData();
  46. }
  47. }
  48. </script>
Add Comment
Please, Sign In to add comment