fetching.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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">kxOuG8jMIgI</a>
  6. <h2>Example Request:</h2>
  7. <span>Request URL:</span>
  8. <a
  9. :href="apiUrl + '/votes?videoId=kxOuG8jMIgI'"
  10. target="_blank"
  11. v-text="apiUrl + '/votes?videoId=kxOuG8jMIgI'"
  12. />
  13. <br />
  14. <span>
  15. Request Method:
  16. <a
  17. href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET"
  18. target="_blank"
  19. >HTTP/GET</a
  20. >
  21. </span>
  22. <br />
  23. <span>Headers:</span>
  24. <br />
  25. <div class="code pa-4">
  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
  30. </div>
  31. <span>Response:</span><br />
  32. <div class="code pa-4">
  33. {
  34. <br />
  35. &nbsp;"id": "kxOuG8jMIgI",<br />
  36. &nbsp;"dateCreated": "2021-12-20T12:25:54.418014Z",<br />
  37. &nbsp;"likes": 27326,<br />
  38. &nbsp;"dislikes": 498153,<br />
  39. &nbsp;"rating": 1.212014408444885,<br />
  40. &nbsp;"viewCount": 3149885,<br />
  41. &nbsp;"deleted": false<br />
  42. }
  43. </div>
  44. <br />
  45. <v-alert border="left" color="orange" text type="info">
  46. <span>An invalid YouTube ID will return status code 404 "Not Found".</span><br />
  47. <span>An incorrectly formatted YouTube ID will return 400 "Bad Request".</span>
  48. </v-alert>
  49. <a :href="endpointUrl" target="_blank" v-text="endpointUrl" />
  50. </div>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. apiUrl: process.env.apiUrl,
  57. };
  58. },
  59. };
  60. </script>
  61. <style scoped>
  62. .code {
  63. color: #aaa;
  64. background: #353535;
  65. border-radius: 0.5rem;
  66. font-family: monospace;
  67. line-height: 2rem;
  68. }
  69. </style>