2017-09-02 20 views

回答

0

您可以在窗口创建代码所在的main.js文件中添加这些API调用。

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 }); 

    });  

    ...  
}); 
+0

感谢您的及时回复。但是,您如何在电子中创建REST API?有什么建议么? –

+0

你可以使用'request' npm模块,我已经更新了我的答案。 – abskmj

+0

太棒了,谢谢。 –

相关问题