CMXX - Included VIN API in cartest

This commit is contained in:
“VeLiTi”
2024-11-16 15:40:23 +01:00
parent f716e80360
commit 974efdf323
7 changed files with 107 additions and 31 deletions

View File

@@ -1126,4 +1126,41 @@ a.document.write(divContents);
a.document.write('</body></html>');
a.document.close();
a.print();
}
}
//------------------------------------------
// decodeVIN api
//------------------------------------------
function decodeVIN(){
var vin = document.getElementById("VIN").value;
var token = document.getElementById("token").innerHTML;
var action = '/v2/vin/'+vin;
var url = link+action;
var bearer = 'Bearer ' + token;
fetch(url, {
method: 'GET',
withCredentials: true,
credentials: 'include',
headers: {
'Authorization': bearer,
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(vin_details=> {
console.log(vin_details);
document.getElementById("year").value = vin_details['year'];
var carbrands = document.getElementById("carbrands");
carbrands.options[carbrands.selectedIndex].value = vin_details['Manufacturer'];
carbrands.options[carbrands.selectedIndex].innerHTML = vin_details['Manufacturer'];
})
.catch(error => {
console.log(error)
})
}