var searchkey; $(document).ready(function(){ $('.message a').click(function(){ $('form').animate({height: "toggle", opacity: "toggle"},"slow"); }); $('.search-btn').click(function() { searchkey= $('.search-movies').val(); }); }); async function submitForm(e){ e.preventDefault(); try { const response = await fetch('https://mkr.thefeathers.in/register', { method: 'POST', headers: new Headers({'content-type': 'application/json'}), body: JSON.stringify({ "username": document.getElementById('formName').value, "email": document.getElementById('formEmail').value, "password": document.getElementById('formPassword').value }) }); const data = await response.json(); //Success code goes here //window.location = "searchmovies.html"; alert(JSON.stringify(data)); $('form').animate({ height: "toggle", opacity: "toggle" }, "slow"); } catch (err) { //Failure alert('Error'); } } var token; async function submitForm1(e){ e.preventDefault(); try { const response = await fetch('https://mkr.thefeathers.in/login', { method: 'POST', headers: new Headers({'content-type': 'application/json'}), body: JSON.stringify({ "username" : document.getElementById('formName1').value, "password" : document.getElementById('formPassword1').value }) }); const data1 = await response.json(); //Success code goes here alert(JSON.stringify(data1)); token = data1.token; window.location = "searchmovies.html"; } catch (err) { //Failure alert('Error'); } } async function search(e){ e.preventDefault(); try { const response = await fetch('https://mkr.thefeathers.in/search/'+searchkey, { method: 'GET', headers: new Headers({'content-type': 'application/json'}), headers: new Headers({ 'Authentication': token }) }); const data = await response.json(); //Success code goes here //window.location = "searchmovies.html"; alert(JSON.stringify(data)); } catch (err) { //Failure alert('Error'); } }