明道云AI字段。生成按钮,点击执行webhook
iamdu2025-03-17 09:14:30明道云 浏览: 1942
// <free_field_name>WebhookButton</free_field_name>
// <file_name>WebhookButton_v1.jsx</file_name>
function WebhookButton({ formData, onClick }) {
const [loading, setLoading] = useState(false);
const handleClick = async () => {
setLoading(true);
// 获取引用字段的值
const targetValue = formData['641c098f2c2835b432d05cf4']?.value;
// 这里可以根据需要处理 targetValue
console.log('可以运行的', { targetValue });
const data = {
yongliang: 23,
chumishu: 23,
kuanhao: "wewe"
};
try {
const response = await fetch('https://api.mingdao.com/workflow/hooks/NjdiOWY4MDU2ZDFlMGI1MjkwMWY4MzE5', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
});
const resultData = await response.json();
console.log(resultData, response);
} catch (error) {
console.error('执行Webhook时出错:', error);
} finally {
setLoading(false);
}
};
return (
<button
className={`h-[36px] px-4 ${loading ? 'bg-gray-400' : 'bg-blue-600'} text-white rounded-md border border-blue-600 hover:bg-blue-700`}
onClick={handleClick}
disabled={loading}
>
{loading ? '执行中...' : '点击执行Webhook'}
</button>
);
}
欢迎留下你的看法
共 0 条评论