P
P
pixal2019-06-05 15:46:39
React Native
pixal, 2019-06-05 15:46:39

How to write such JSON to AsyncStorage (React Native)?

Here is an array I get through axios

{"response":[{"id":"1","cat_id":"1","title":"\u041f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u043f\u0438\u0442\u0430\u043d\u0438\u044f","get_catalog":"campony_ru","language":"1","visible":null},{"id":"2","cat_id":"2","title":"\u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0438 \u0440\u0435\u043c\u043e\u043d\u0442","get_catalog":"campony_ru","language":"1","visible":null},{"id":"3","cat_id":"3","title":"\u041e\u0434\u0435\u0436\u0434\u0430 \u0438 \u043e\u0431\u0443\u0432\u044c","get_catalog":"campony_ru","language":"1","visible":null},{"id":"4","cat_id":"4","title":"\u0414\u0435\u0442\u0441\u043a\u0438\u0435 \u0438\u0433\u0440\u0443\u0448\u043a\u0438","get_catalog":"campony_ru","language":"1","visible":null}]}

I need to access response in AsyncStorage and get its contents

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-05
@rockon404

Simple example:

const { data } = await axios.get('/someUrl');

await AsyncStorage.setItem('somekey', JSON.stringify(data.response));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question