I want to get original object that was passed to reactive() from Vue 3 proxy. This is my code:
const token: any = reactive(new Token());
console.log(token.target);//prints undefined
Could anyone say how to do it?
reactive returns JavaScript Proxy which doesn't expose original object, unless a proxy is revokable.
Original object can be accessed through __v_raw property on reactive proxy, it's not a part of public API and shouldn't be relied on. Public API is toRaw:
const token = reactive(rawToken);
const rawToken = toRaw(token);
If original object is needed then the reference shouldn't be discarded:
const rawToken = new Token();
const token = reactive(rawToken);