当前位置:网站首页>How does electron net send a post request
How does electron net send a post request
2022-04-21 12:21:00 【October oooo】
electron net How to send post request
use electron Of net send out post When asked , What I'm not sure is how to set the sending method , For a long time , I tried for a long time , It's summed up
Request mode
// introduce net
const {
net } = require('electron')
let userInfo = {
email: kylebing@163.com,
password: '1234'
}
// 1. newly build net.request request
const request = net.request({
headers: {
'Content-Type': 'application/json',
},
method: 'POST',
url: 'http://localhost:3000/user/login'
})
// 2. adopt request.write() Method , Sent post The requested data needs to be serialized first , Into plain text
request.write(JSON.stringify(userInfo))
// 3. Processing return results
request.on('response', response => {
response.on('data', res => {
// res yes Buffer data
// adopt toString() It can be changed to String
// See : https://blog.csdn.net/KimBing/article/details/124299412
let data = JSON.parse(res.toString())
})
response.on('end', () => {
})
})
// 4. Remember to close the request
request.end()
The data received by the server is like this , With nodejs Of express For example , be in req.body in

版权声明
本文为[October oooo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211211457127.html
边栏推荐
- Chris LATTNER, father of llvm: the golden age of compilers
- 国网上海直流充电桩专利公布:保证安全运行,全流程检测,分级运维
- 上海疫情中,新消费品牌们的坚守、放弃与救赎
- 【数据可视化应用】绘制双变量映射地图(附R语言代码)
- 【软件测试系列五】《软件测试申请表》
- Three. JS learning project -- 3D data visualization of anti US aggression and aid Korea
- 教你轻松解决CSRF跨站请求伪造攻击
- 海量数据2021年创收4.21亿元,数据库产品毛利率提升8.78%!
- Seven ways of text reading based on C
- Scala installation and development environment configuration tutorial
猜你喜欢

【数据可视化应用】绘制双变量映射地图(附R语言代码)

The basic software products of xinghuan science and technology have been fully implemented and blossomed, bringing "Star" momentum to the digital transformation of enterprises

BEVSegFormer:一个来自任意摄像头的BEV语义分割方法

Reverse crawler 30 verification code of a fourth generation slider

给定字符串提取姓名(字符串、list、re“零宽断言”)

Berkeley, Samsung | a fast post training converter pruning framework

Yyds dry goods inventory a common error in a web crawler

Daily AI frontier terminology: active learning

S parameter introduction

Live broadcast of changes in the Jianghu: Li Jiaqi is trapped in a luxury house, Luo Yonghao fades out, and Weiya Sydney helps broadcast it
随机推荐
《深度学习》学习笔记(六)
笑死!程序员延寿指南开源了
Study notes of "deep learning" (VII)
虚拟货币已然没有市场,为何还能对一些人产生不小的诱惑?
[software test series Xi] stress test scenario and test case template
Intermediary encircles little red book
The simpler the Oracle database machine is, the more reliable it is. Oracle buried the "colored egg" 11 years ago
【数据可视化应用】绘制双变量映射地图(附R语言代码)
[software test series x] stress test scheme
Notepad + + how to copy multiple lines and paste them to the corresponding position
ASM插桩之美
The non display of markerarray caused by the ROS version problem has been solved
[software test series 8] software project test report
达梦数据库市场份额增速行业领先,盈利能力大幅提升
分享几款我在高频使用的 Chrome 浏览器插件,每一个都好用到飞起
pycharm 跳转到指定行
国内期货开户去哪里开可以费率低,公司又安全?
The small program rotates the mobile phone to push the stream, and the remote pull stream picture is cut
State Grid Shanghai DC charging pile patent announcement: ensure safe operation, whole process detection, hierarchical operation and maintenance
Aaai2022 | unbiased temporal knowledge reasoning based on probabilistic soft logic