@ flatfile/ sdk (中文(简体) )
安装
npm install @flatfile/sdk
开始
通过点击 Flatfile 仪表板左下角的切换,确定您处于开发者模式 .
获取嵌入式身份证
首先,拿你嵌入的ID 为您想要嵌入的门户。 您可以在平面文件仪表板上的编辑门户页面中找到这个, 它应该看起来像这样:
76aa0b10-d7f8-4dc7-a007-4a791736eed1
嵌入您的门户
使用以下代码将您的门户网站嵌入您的应用程序 :
import { Flatfile } from "@flatfile/sdk";
// find this in your Flatfile dashboard after creating a new Portal
const EMBED_ID = "";
// use this wherever you need to trigger an import
export function importData() {
Flatfile.requestDataFromUser({
embedId: EMBED_ID,
user: { id: 99, name: "John Doe", email: "[email protected]" },
org: { id: 77, name: "Acme Inc." },
onData(chunk, next) {
/* handle submitted data here */
},
});
}
// change this to whatever DOM trigger you want to use
document.getElementById("button").addEventListener("click", importData);
点击您传递到的元素时, 此选项应打开门户 document.getElementById。通过上传一个CSV来尝试一下,然后看到你的平分仪表盘中出现你的被清理的数据!
检查额外的选项 requestDataFromUser 输入 Flatife 开发者文件。 。 。 .
今后的步骤
看看这个 平面文件开发者 Docs 看看你的门户网站在生产方面需要什么,包括: