Next.js Discord

Discord Forum

randomUUID is not a function

Answered
gin posted this in #help-forum
Open in Discord
ginOP
Yeah so idk why but randomUUID is somehow not recognized
Answered by gin
ah found out it is only available under https context
View full answer

3 Replies

ginOP
import {randomUUID} from "crypto";
useEffect(() => {
    async function update() {
      setSelfScribbleUser({
        _id: self?._id || randomUUID(),
        name: self?.profile.username || "Anonymous",
        picture: self?.profile.social.display.picture.source || (await randomDog()),
      });
    }
    update();
  }, [self]);
ive been using randomUUID for ages but now i get this error ->
TypeError: (0 , crypto__WEBPACK_IMPORTED_MODULE_4__.randomUUID) is not a function
ginOP
ah found out it is only available under https context
Answer