Answer the question
In order to leave comments, you need to log in
How to make it so that the data that has just been loaded into LocalStorage can be immediately used in the code?
I have requests to the API on my site, one of the parameters for the request is town_id.
And the value that we substitute there is taken from LocalStorage
town_id: JSON.parse(localStorage.getItem('town')).id,
. We put it there, automatically determining the user's location and sending the necessary request to the API. As a result, we get such an object{
"id": 2379,
"name": "г. Москва",
"region": "Московская обл.",
"lat": "55.755814",
"long": "37.617635",
"update_at": 1489006800
};
console.log((JSON.parse(localStorage.getItem('town'))));
returns null. And therefore there is nothing to put in town_id. Answer the question
In order to leave comments, you need to log in
You don’t have to set the average difficulty, just there is no permission for the command
Run with sudo, by the way, you also installed opencv yesterday
And you may encounter another problem
In the OPENCV_EXTRA_PATH= parameter, the path to the modules, that is, the library that you downloaded along with the main one
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question