CMXX - Included VIN API in cartest
This commit is contained in:
@@ -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)
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user