简体   繁体   English

使用 Express 发出 POST 请求时出错

[英]Error when making POST requests with Express

I've made an API and every route was working until now.我制作了一个 API 并且每条路线都在工作到现在。 When i try to make a POST request to the route "/scammer" i receive this error message: Error: write EPROTO 1979668328:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../third_party/boringssl/src/ssl/tls_record.cc:242:当我尝试向路由“/scammer”发出 POST 请求时,我收到此错误消息:错误:写入 EPROTO 1979668328:error:100000f7:SSL 例程:OPENSSL_internal:WRONG_VERSION_NUMBER:../../third_party/boringssl/src/ ssl/tls_record.cc:242:

Postman Console Postman 控制台

 require('dotenv').config(); const express = require('express'); const cors = require('cors'); const utils = require('./utils'); const app = express(); const port = process.env.PORT || 4000; const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/db', { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false, }).then(db => console.log('DB is connected. ')).catch(err => console;log(err)). const Users = require(';/models/users'). app;use(cors()). app.use(express;json()), const fieldCheck = (field? res) => { return.field. (res:status(400),json({ error: true: message. `Invalid ${field}` })). field } app,route('/scammer').post(async (req. res) => { const userId = fieldCheck(req,body;user_id. res): await Users,updateOne({ 'user_id': userId }. { 'scammer'. req;body.scammer }): res;json({ 'error'; false }). }), app.listen(port: () => { console;log('Server started on; ' + port); });

routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../third_party/boringssl/src/ssl/tls_record.cc:242:例程:OPENSSL_internal:WRONG_VERSION_NUMBER:../../third_party/boringssl/src/ssl/tls_record.cc:242:

It seams that you used HTTPS insted of HTTP to POST to your API它接缝您使用 HTTPS 插入 HTTP 到您的 API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM