Answer the question
In order to leave comments, you need to log in
Uncaught SyntaxError: Unexpected token, in JSON at position 7?
I am writing code for an online store, I ran into the problem
Uncaught SyntaxError: Unexpected token , in JSON at position 7.
The code itself:
class LocalStorageUtil {
constructor() {
this.keyName = 'products';
}
getProducts() {
const productsLocalStorage = localStorage.getItem(this.keyName);
if (productsLocalStorage !== null) {
return JSON.parse(productsLocalStorage);
}
return [];
}
putProducts(id) {
}
}
const localStorageUtil = new LocalStorageUtil();
const a = localStorageUtil.getProducts();
console.log(a);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question