Skip to content

Instantly share code, notes, and snippets.

@JerryNyoike
Created July 31, 2019 06:50
Show Gist options
  • Save JerryNyoike/ab5761a94fdb6385541dfe7b8e7fba5d to your computer and use it in GitHub Desktop.
Save JerryNyoike/ab5761a94fdb6385541dfe7b8e7fba5d to your computer and use it in GitHub Desktop.
const url = 'http://localhost:5050/vehicles/' + search_params.get("id");
fetch(url)
.then(response=>{
if (response.ok){
return response.json();
}
})
.then(jresp=> {
get_vehicle_images(jresp);
populate_vehicle_details(jresp);
})
.catch(error=>{console.log('Error: ' + error)});
function book(){
fetch(book_url, {
headers:{"Autorization": "Bearer " + localStorage.aft_token},
method: 'POST'
})
.then(response => {
if (response.ok) {
return response.json();
}
throw new Error("Error caught")
})
.then(resp=>{
alert(resp.message);
window.location.assign("../../index.html");
})
.catch(error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment