Получение пост-запроса из django python с помощью Node JS
Используя Node JS, я хочу получить данные, которые я разместил.
в моих представлениях. py
if request.method == 'POST':
post_data = json.loads(request.POST.get("data"))
response = requests.post('http://localhost:3000/path/', data={
'data': request.POST.get("data")})
в моем node js
const bodyParser = require("body-parser")
const jsonParse = bodyParser.json()
router.post("/path", jsonParse, (req, res) => {
//I have some function here, but I needed to use the data from my
django views.
console.log(req.body) //the console is {}, I want to get the data
that I posted using the django views//})
Возможно, мой подход неправильный. Я новичок в node JS, поэтому и прошу помощи. Я открыт для любых предложений. Представления django работают. Я просто не знаю, как получить это в Node JS способом
По какой-то причине комментарий сэра Харриса заставил меня проверить мои представления django. И я пришел к решению. Мой node JS теперь читает его
data={'name':request.POST.get("device")}
headers = {'content-type': 'application/json'}
response = requests.post('http://localhost:3000/path', data=json.dumps(data), headers=headers)