【问题标题】:Can't make posts requests in Electron using axios (makes only get requests)无法使用 axios 在 Electron 中发出帖子请求(仅发出获取请求)
【发布时间】: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


    【解决方案1】:

    您缺少标题

    应用程序/json

    【讨论】:

      猜你喜欢
      • 2020-09-17
      • 2020-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-07
      • 1970-01-01
      • 2019-08-10
      • 1970-01-01
      相关资源
      最近更新 更多