I am trying to grab XSOQSVPbATbRYa94ZuXs
from the pid
parameter using
URLSearchParams
.
Here is my URL: http://localhost:3000/edit-product?pid=Z4HLrHGZ1ikKIwlEVkM6
Here is my code:
useEffect(() => {
if (user) {
const params = new URLSearchParams(location.search);
const pid = params.get("pid");
} else {
setProducts("");
}
}, [user]);
Any idea why I'm receiving the following error:
TypeError: Cannot read property 'search' of undefined