let requestData = {
products: [
{
description: "product1",
barcode: "123456",
price: 10,
note: "note1"
},
{
description: "product2",
barcode: "654321",
price: 20,
note: "note2"
}
]
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:8000/api/v1/cotacao", true);
xhr.setRequestHeader("Content-Type", "application/json");
let csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute("content");
xhr.setRequestHeader("X-CSRF-TOKEN", csrfToken);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText);
}
};
xhr.send(JSON.stringify(requestData));
xhr.setRequestHeader("X-CSRF-TOKEN", document.querySelector('meta[name="csrf-token"]')?.getAttribute("content")); return document.querySelector('meta[name="csrf-token"]').getAttribute("content") = Uncaught TypeError: Cannot read properties of null (reading 'getAttribute') at :1:51