KuoHsiangYu

testFetchAPI

Nov 17th, 2025
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* 打後端Web API */
  2.  
  3. // TODO: 等等再去重寫
  4.  
  5. async function getTableHeader() {
  6.   let tableHeader = [];
  7.   try {
  8.     const response = await fetch("https://www.oooDomain.com:4000/tableHeader", {
  9.       method: "GET",
  10.     });
  11.     const articles = await response.json();
  12.     tableHeader = Array.from(articles);
  13.   } catch (error) {
  14.     console.log("error ", error);
  15.   }
  16.  
  17.   return tableHeader;
  18. };
  19.  
  20. async function getTableBody() {
  21.   let tableBody = [];
  22.   try {
  23.     const response = await fetch("https://www.oooDomain.com:4000/tableBody", {
  24.       method: "GET",
  25.     });
  26.     const articles = await response.json();
  27.     tableBody = Array.from(articles);
  28.   } catch (error) {
  29.     console.log("error ", error);
  30.   }
  31.  
  32.   return tableBody;
  33. };
  34.  
  35. export default {
  36.   getTableHeader,
  37.   getTableBody
  38. };
Advertisement
Add Comment
Please, Sign In to add comment