Skip to content

โ€‹

js
fetch(
  "http://console.hlt100.com/uac/auth/printWaybill?waybillCodes=null&orderCodes=DD23021503062264,DD23021502571723",
  {
    method: "get",
    headers: {
      "Content-Type": "application/pdf;charset=utf-8",
    },
    // body: JSON.stringify({
    //     billType: 123123,
    //     segmentCode: 123132,
    //     deliveryDistribution: 1231231
    // })
  }
)
  .then((response) => response.blob())
  .then((blob) => {
    const url = URL.createObjectURL(blob); // ๅˆ›ๅปบๆŒ‡ๅ‘ blob ็š„ URL
    console.log(url, "url");
    this.openPdfInNewTab(url); // ่ฐƒ็”จๆ‰“ๅผ€ๆ–ฐ้กต้ข็š„ๆ–นๆณ•
  })
  .catch((error) => {
    console.error("ๅ‘็”Ÿ้”™่ฏฏ:", error);
  });
js
try {
  const response = await fetch(
    "http://console.hlt100.com/uac/auth/printWaybill?waybillCodes=null&orderCodes=DD23021503062264,DD23021502571723",
    {
      method: "get",
      headers: {
        "Content-Type": "application/pdf;charset=utf-8",
      },
    }
  );

  const blob = await response.blob(); // ็ญ‰ๅพ…ๅ“ๅบ”ๅนถ่ฝฌๆขไธบ Blob

  const url = URL.createObjectURL(blob); // ๅˆ›ๅปบๆŒ‡ๅ‘ blob ็š„ URL

  
  this.openPdfInNewTab(url); // ่ฐƒ็”จๆ‰“ๅผ€ๆ–ฐ้กต้ข็š„ๆ–นๆณ•
} catch (error) {
  console.error("ๅ‘็”Ÿ้”™่ฏฏ:", error);
}

Released under the MIT License.