【发布时间】:2019-11-20 21:40:31
【问题描述】:
我正在使用 Electron 和 Axios 构建一个简单的应用程序来发出 http 请求。但是每次我尝试向我的服务器发出 post 请求时,它只会发出一个 get 请求,正如我在 Chrome Devtools 中看到的那样。我不明白这里发生了什么。
在服务器端,我有一个只接受 POST 请求的 Laravel 后端应用程序。
index.html
<html>
<body>
<script src="axios.min.js"></script>
<script>
axios.post('https://www.example.com/api/users/', {
firstName: 'Fred',
lastName: 'Flintstone'
})
</script>
</body>
</html>
main.js
const { app, BrowserWindow } = require('electron')
let win
function createWindow () {
win = new BrowserWindow({
width: 530,
height: 520,
webPreferences: {
nodeIntegration: true
},
})
win.loadFile('index.html')
win.setAlwaysOnTop(true)
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
app.quit()
})
【问题讨论】:
标签: javascript http https electron axios