Anyone know how to use `zod` library with a dynami...
# typescript
h
Anyone know how to use
zod
library with a dynamic resource provider? Inside my provider's
create
function it blows up like so:
Copy code
...which indirectly referenced
   function 'bound parse': which could not be serialized because
     it was a native code function.
Ok, I was able to work around this by using the
axios
library a little differently
Instead of
Copy code
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>(`${somePath}/blah/${name}`, {
		somefield: baz,
	});
	return response.parse(response.data).bar;
};
use the generic form of the call to axios instead
Copy code
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;
};
Anyone know a workaround when there's not an alternative like above? e.g. calling
crypto.randomInt
?