helpful-easter-62786
10/18/2022, 5:54 PMzod
library with a dynamic resource provider?
Inside my provider's create
function it blows up like so:
...which indirectly referenced
function 'bound parse': which could not be serialized because
it was a native code function.
axios
library a little differentlyexport const fooResponse = z.object({
bar: z.string(),
});
export type FooResponse = z.infer<typeof fooResponse>;
export const makeHttpCall = async (
ax: AxiosInstance,
name: string,
baz: string
): Promise<string> => {
const response = await <http://ax.post|ax.post>(`${somePath}/blah/${name}`, {
somefield: baz,
});
return response.parse(response.data).bar;
};
export const fooResponse = z.object({
bar: z.string(),
});
export type FooResponse = z.infer<typeof fooResponse>;
export const makeHttpCall = async (
ax: AxiosInstance,
name: string,
baz: string
): Promise<string> => {
const response = await <http://ax.post|ax.post><FooResponse>(`${somePath}/blah/${name}`, {
somefield: baz,
});
return response.bar;
};
crypto.randomInt
?