โ
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);
}