fix: monkey patch Client.call to return plain objects and avoid nextjs serialization error
This commit is contained in:
parent
b9f74a8c87
commit
cd6a91ba9a
@ -10,6 +10,19 @@ if (typeof console !== 'undefined' && !(console as any)._appwritePatchedServer)
|
||||
}
|
||||
originalWarn(...args);
|
||||
};
|
||||
|
||||
// Monkey-patch Client.prototype.call to always return plain objects
|
||||
const originalCall = Client.prototype.call;
|
||||
if (originalCall) {
|
||||
Client.prototype.call = async function (this: any, ...args: any[]) {
|
||||
const res = await originalCall.apply(this, args);
|
||||
if (res && typeof res === 'object') {
|
||||
return JSON.parse(JSON.stringify(res));
|
||||
}
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
(console as any)._appwritePatchedServer = true;
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,19 @@ if (typeof console !== 'undefined' && !(console as any)._appwritePatchedClient)
|
||||
}
|
||||
originalWarn(...args);
|
||||
};
|
||||
|
||||
// Monkey-patch Client.prototype.call to always return plain objects
|
||||
const originalCall = Client.prototype.call;
|
||||
if (originalCall) {
|
||||
Client.prototype.call = async function (this: any, ...args: any[]) {
|
||||
const res = await originalCall.apply(this, args);
|
||||
if (res && typeof res === 'object') {
|
||||
return JSON.parse(JSON.stringify(res));
|
||||
}
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
(console as any)._appwritePatchedClient = true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user