【发布时间】:2018-06-14 20:49:54
【问题描述】:
我在 SO 上找不到任何类似的问题。
有人可以向我展示一个如何在 POST 中使用 loadURL 的示例吗?我目前正在做以下事情
const url = firebaseCloudFunctionURL+"/endpointAPI";
const webview = document.createElement('webview');
webview.setAttribute("src", "https://www.nytimes.com/"); // forces dom-ready event to be called
webview.addEventListener('dom-ready', () => {
const postDict = {
query: "test_string"
};
webview.loadURL(url, {postData: postDict});
});
但网络服务器显示请求正文为空。
(使用 Firebase 云功能)
exports.endpointAPI = functions.https.onRequest((req, res) => {
const test = req.body.shop;
console.log("req.body "+ JSON.stringify(req.body));
});
在日志中产生“req.body {}”。
electron documentation 中的 postData 是用 UploadRawData[] 写的。但是没有示例代码。有没有人让它工作?
【问题讨论】:
-
你成功了吗?