Added QBXML Creation and posting to localhost. BOD-83

This commit is contained in:
Patrick Fic
2020-05-28 09:09:30 -07:00
parent 5d28896925
commit 681cbea4fc
6 changed files with 532 additions and 7 deletions

View File

@@ -37,9 +37,66 @@ export default connect(
link.click();
};
const handleLocal = async () => {
try {
const response = await axios.post(
"http://localhost:1337/qb/receivables",
{ jobId: "661dd1d5-bf06-426f-8bd2-bd9e41de8eb1" },
{
headers: {
Authorization: `Bearer ${await auth.currentUser.getIdToken(true)}`,
},
}
);
console.log("handle -> result", response);
} catch (error) {
console.log("error", JSON.stringify(error));
}
};
const handleQbxml = async () => {
const response = await axios.post(
"/accounting/qbxml/receivables",
{ jobId: "661dd1d5-bf06-426f-8bd2-bd9e41de8eb1" },
{
headers: {
Authorization: `Bearer ${await auth.currentUser.getIdToken(true)}`,
},
}
);
console.log("handle -> result", response);
try {
const response2 = await axios.post(
"http://localhost:1337/qb/receivables",
response.data,
{
headers: {
Authorization: `Bearer ${await auth.currentUser.getIdToken(true)}`,
},
}
);
console.log("handle -> result", response2);
} catch (error) {
console.log("error", error, JSON.stringify(error));
}
// const url = window.URL.createObjectURL(new Blob([response.data]));
// const link = document.createElement("a");
// link.href = url;
// link.setAttribute(
// "download",
// response.headers.filename || "receivables.iif"
// ); //or any other extension
// document.body.appendChild(link);
// link.click();
};
return (
<div>
<button onClick={handle}>Hit with Header.</button>
<button onClick={handleLocal}>Hit Localhost with Header.</button>
<button onClick={handleQbxml}>Qbxml</button>
</div>
);
});