fetching.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div style="line-height: 3rem">
  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. >
  8. <h2>Example Request:</h2>
  9. <span>Request URL:</span>
  10. <a
  11. :href="apiUrl + '/votes?videoId=kxOuG8jMIgI'"
  12. target="_blank"
  13. v-text="apiUrl + '/votes?videoId=kxOuG8jMIgI'"
  14. />
  15. <br />
  16. <span>
  17. Request Method:
  18. <a
  19. href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET"
  20. target="_blank"
  21. >HTTP/GET</a
  22. >
  23. </span>
  24. <br />
  25. <span>Headers:</span>
  26. <br />
  27. <div class="code pa-4">
  28. Accept: text/html,application/xhtml+xml,application/xml;q=0.9<br />
  29. Pragma: no-cache<br />
  30. Cache-Control: no-cache<br />
  31. Connection: keep-alive
  32. </div>
  33. <span>Response:</span><br />
  34. <div class="code pa-4">
  35. {
  36. <br />
  37. &nbsp;"id": "kxOuG8jMIgI",<br />
  38. &nbsp;"dateCreated": "2021-12-20T12:25:54.418014Z",<br />
  39. &nbsp;"likes": 27326,<br />
  40. &nbsp;"dislikes": 498153,<br />
  41. &nbsp;"rating": 1.212014408444885,<br />
  42. &nbsp;"viewCount": 3149885,<br />
  43. &nbsp;"deleted": false<br />
  44. }
  45. </div>
  46. <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. <script>
  59. export default {
  60. data() {
  61. return {
  62. apiUrl: process.env.apiUrl,
  63. };
  64. },
  65. };
  66. </script>
  67. <style scoped>
  68. .code {
  69. color: #aaa;
  70. background: #353535;
  71. border-radius: 0.5rem;
  72. font-family: monospace;
  73. line-height: 2rem;
  74. }
  75. </style>