i tryng to load all items saved in my asyncstorage, but my response does not return in json format, returns in this format:
[["engineyard", "{\"login\":\"engineyard\",\"id\":81,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjgx\",\"url\":\"https://api.github.com/orgs/engineyard\",\"repos_url\":\"https://api.github.com/orgs/engineyard/repos\",\"events_url\":\"https://api.github.com/orgs/engineyard/events\",\"hooks_url\":\"https://api.github.com/orgs/engineyard/hooks\",\"issues_url\":\"https://api.github.com/orgs/engineyard/issues\",\"members_url\":\"https://api.github.com/orgs/engineyard/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/engineyard/public_members{/member}\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/81?v=4\",\"description\":\"\"}"], ["errfree", "{\"login\":\"errfree\",\"id\":44,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjQ0\",\"url\":\"https://api.github.com/orgs/errfree\",\"repos_url\":\"https://api.github.com/orgs/errfree/repos\",\"events_url\":\"https://api.github.com/orgs/errfree/events\",\"hooks_url\":\"https://api.github.com/orgs/errfree/hooks\",\"issues_url\":\"https://api.github.com/orgs/errfree/issues\",\"members_url\":\"https://api.github.com/orgs/errfree/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/errfree/public_members{/member}\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/44?v=4\",\"description\":null}"]]
but when i get only one item his return in json format, in this format i can't save in array to map
My code
const getOrgsSaved = async () => { let value = [] try { const keys = await AsyncStorage.getAllKeys(); const Orgs = await AsyncStorage.multiGet(keys) return Orgs } catch (e) { console.log(e) return e; }}//my function where i get the items const Main: React.FC = () => { const [orgsSave, setOrgsSaved] = useState<Array<Orgs>>([]) const [orgsData, setOrgsData] = useState<Array<Orgs>>([]) useEffect(() => { loadOrgs() getOrgsSaved() },[]) const loadOrgs = () =>{ Services.getOrgs() .then(response =>{ setOrgsData(response.data) }) .catch(e =>{ console.log(e) }) } function getOrgsSaved() { Services.getOrgsSaved() // here i get the response .then(response => { console.log('get',response) setOrgsSaved(response) }) } return (<Box flex = {1} ><Navbar/><SubHeader/><OrgsList data = {orgsData}/><Footer/></Box> );}export default Main;
i tried to use JSON.parse but returns this error
[SyntaxError: JSON Parse error: Unexpected identifier "engineyard"]