I am using redux saga for asynchronous calls, I made an API call and store the data in local storage but eslint/prettier is auto adding parenthesis to assignment operator at the end of line. I don't find any relevant solution.
function fetchData(services: requiredServices) {
return function*() {
try {
let datafromlocalStorage = JSON.parse(localStorage.getItem("studentInfo") || '{}');
if (datafromlocalStorage && Object.keys(datafromlocalStorage).length < 1) {
const { data } = yield call(services.dataManagement.getData);
datafromlocalStorage = data;
localStorage.setItem("studentInfo", JSON.stringify(data));
}
yield put(actions.saveContnet(datafromlocalStorage))
} catch(e) {
}
}
}
It's giving error at the last line of try block, saying expression expected.
The
catch
block is expecting at least one statement. If you just need to catch any thrown errors or rejected promises and don't care to handle them, then add a comment line, e.g// ignored
.