KinoOfficial / ReactCourse

0 stars 0 forks source link

fetch #5

Open KinoOfficial opened 1 year ago

KinoOfficial commented 1 year ago

function logout () { fetch('http://localhost:5005' + '/admin/auth/logout', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: Bearer ${token} }, body: JSON.stringify() }).then(json => { return json.json() }).then(data => { if (data.error) { alert(data.error) } else { alert('Successfully Logout!') navigate('/') } return data }).catch(data => { alert(data) }) }