How do I save json tokens ?
I have a Django back end that sends me a token after I log in, but I can't seem to figure out how to store that token.
answers online give a vague 'use SecureStore' but when I go to the documentation I cant seem to figure it out, here's what my code looks like:
`async function save(key, value) {
await SecureStore.setItemAsync(key, value);
}`
`async function SubmitLogin(){
try {
await fetch('[http://192.168.100.11:100/api/login/](http://192.168.100.11:100/api/login/)', {
method:'post',
mode:'no-cors',
headers: {
'Accept':'application/json',
'Content-Type':'application/json'
},
body: JSON.stringify({
username: username,
password : password,
})
}).then(response => response.json())
.then(response => save('token', response\[Object.keys(response)\[0\]\]))
.then(data => console.log(data))
.catch(error => console.log(error));
} catch (e) {
console.log(e);
}
}`
should i not do .then(response => save('token', response\[Object.keys(response)\[0\]\])\
?