fetching.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div>
  3. <h1 class="primary--text">Basic Fetching Tutorial</h1>
  4. <span>Example to get votes of a given YouTube video ID:</span>
  5. <a href="https://youtube.com/watch?v=kxOuG8jMIgI" target="_blank"
  6. >kxOuG8jMIgI</a
  7. ><br /><br />
  8. <h2>Example Request:</h2>
  9. <span><b>Request URL:</b></span>
  10. <a
  11. :href="apiUrl + '/votes?videoId=kxOuG8jMIgI'"
  12. target="_blank"
  13. v-text="apiUrl + '/votes?videoId=kxOuG8jMIgI'"
  14. /><br />
  15. <span
  16. ><b>Request Method:</b>
  17. <a
  18. href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET"
  19. target="_blank"
  20. >HTTP/GET</a
  21. ></span
  22. ><br />
  23. <span><b>Headers:</b></span
  24. ><br />
  25. <code class="code">
  26. Accept: text/html,application/xhtml+xml,application/xml;q=0.9<br />
  27. Pragma: no-cache<br />
  28. Cache-Control: no-cache<br />
  29. Connection: keep-alive </code
  30. ><br />
  31. <span><b>Response:</b></span
  32. ><br />
  33. <div class="code">
  34. <code style="background-color: rgba(0, 0, 0, 0)">
  35. {<br />
  36. "id": "kxOuG8jMIgI",<br />
  37. "dateCreated": "2021-12-20T12:25:54.418014Z",<br />
  38. "likes": 27326,<br />
  39. "dislikes": 498153,<br />
  40. "rating": 1.212014408444885,<br />
  41. "viewCount": 3149885,<br />
  42. "deleted": false<br />
  43. }
  44. </code>
  45. </div>
  46. <br /><br />
  47. <v-alert border="left" color="orange" text type="info">
  48. <span>An invalid YouTube ID will return status code 404 "Not Found".</span
  49. ><br />
  50. <span
  51. >An incorrectly formatted YouTube ID will return 400 "Bad
  52. Request".</span
  53. >
  54. </v-alert>
  55. <a :href="endpointUrl" target="_blank" v-text="endpointUrl" />
  56. </div>
  57. </template>
  58. <style scoped>
  59. .code {
  60. width: 100%;
  61. background: #353535;
  62. border-radius: 3px;
  63. }
  64. </style>
  65. <script>
  66. export default {
  67. data() {
  68. return {
  69. apiUrl: process.env.apiUrl,
  70. };
  71. },
  72. };
  73. </script>