How do i convert a string to objectId
import { ObjectId } from 'bson';
const fetchData = async () => {
try {
const response = await APIKit.get(HUB_LAYOUT_URL);
const hubData = await response.data
const id = new ObjectId( hubData.id );
console.log(typeof(id), 'id'); // logs to object not objectId
if(hubData) {
createHubLayout( hubData, realm )
}
} catch (error) {
console.log(error, 'error');
}
};
And even if i insert into Realm Db , it throws an error