Created
July 31, 2019 06:50
-
-
Save JerryNyoike/ab5761a94fdb6385541dfe7b8e7fba5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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