【发布时间】:2017-09-02 19:36:34
【问题描述】:
我想在显示我的应用程序的任何窗口之前对 RESTful API 提出一些请求。有谁知道这样做的好方法?谁能举个例子?
非常感谢。
【问题讨论】:
标签: json spring-boot electron restful-url
我想在显示我的应用程序的任何窗口之前对 RESTful API 提出一些请求。有谁知道这样做的好方法?谁能举个例子?
非常感谢。
【问题讨论】:
标签: json spring-boot electron restful-url
您可以将这些 API 调用添加到窗口创建代码所在的 main.js 文件中。
app.on('ready', function () {
//make api calls
var request = require('request');
request('http://www.google.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
// Create the browser window.
mainWindow = new BrowserWindow({ width: 1000, height: 625 });
});
...
});
【讨论】:
request npm 模块,我已经更新了我的答案。