App Screen 3 (UI + Backend integration)

Blog post 6.1 | Hasura Internship

Screen Three

The user can update events from this screen.

token = getCookie(“cookie_name”);
userId = getCookie(“cookie_user”);
$.ajax({
url: dataUrl,
method: ‘post’,
headers: {
‘Authorization’: ‘Bearer ‘ + token,
‘Content-Type’: ‘application/json’
},
data: JSON.stringify({
“type”: “insert”,
“args”: {
“table”: “publish”,
“objects”: [{“description”: $(‘#description’).val(),
“file_id”: $(‘#my_file’).val(),
“user_id”: userId}]
}
})
}).done(function(){
console.log(‘updated’);
window.location = ‘/my_events’;
}).fail(function(){
console.log(‘failed to update’);
});

The app redirects to my events when the post is updated successfully.