CCCPaste

testFetchAPI

/* 打後端Web API */

// TODO: 等等再去重寫

async function getTableHeader() {
  let tableHeader = [];
  try {
    const response = await fetch("https://www.oooDomain.com:4000/tableHeader", {
      method: "GET",
    });
    const articles = await response.json();
    tableHeader = Array.from(articles);
  } catch (error) {
    console.log("error ", error);
  }

  return tableHeader;
};

async function getTableBody() {
  let tableBody = [];
  try {
    const response = await fetch("https://www.oooDomain.com:4000/tableBody", {
      method: "GET",
    });
    const articles = await response.json();
    tableBody = Array.from(articles);
  } catch (error) {
    console.log("error ", error);
  }

  return tableBody;
};

export default {
  getTableHeader,
  getTableBody
};