mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
🚀 Add new /templates utility + add support for web components
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
interface ReactComponentParams {
|
||||
code: string;
|
||||
name: string;
|
||||
typescript: boolean;
|
||||
}
|
||||
|
||||
export const getReactCode = async (
|
||||
params: ReactComponentParams
|
||||
): Promise<{ data?: string; error?: string }> => {
|
||||
try {
|
||||
const getCode = await fetch('/api/svgs/svgr', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
});
|
||||
const data = await getCode.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
return { error: `⚠️ getReactCode: An error has ocurred - ${error}` };
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user