npm install body-parser
const express = require('express');
const { v4: uuidv4 } = require('uuid');
const app = express();
const port = 3000;
const bodyParser = require('body-parser');
app.use(express.urlencoded({ extended: false }))
app.use(express.json());
app.use(bodyParser.json())
app.post('/api/text',(req, res) => {
console.log("---", req.body);
res.send("text");
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
req.on('end', () => {
console.log("---", body);
});
const express = require('express');
const { v4: uuidv4 } = require('uuid');
const app = express();
const port = 3000;
app.use(express.urlencoded({ extended: false }))
app.use(express.json());
app.post('/api/text',(req, res) => {
let body = '';
req.on('data', chunk => {
body += chunk.toString();
});
req.on('end', () => {
console.log("---", body);
});
res.send("text");
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
/a-яё/i
str.match(/\d+/g).join('.')
$("input").focus();
document.querySelector('input').setAttribute('readonly','readonly');
<?php
if($_SERVER["REQUEST_METHOD"]=="POST"]){
print_r($_POST);
if (!empty($_POST["name"]) && !empty($_POST["email"])){
doSomeMagic($_POST);
}
else {
echo "Поля name или email не заполнены!";
}
}
else {
echo "Метод передачи данных не является POST-запросом!";
}
?>