Eine node.js-API erstellen – ein anderer Bedarf

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Eine node.js-API erstellen – ein anderer Bedarf

by Guest » 03 Jan 2025, 08:17

Ich weiß nicht, wie ich den Code für den Kunden sichtbar machen kann, nachdem der Kunde das Formular gesendet hat, und ich weiß auch nicht, wie ich den Kunden dazu bringen kann, mehr als ein Formular (mehrmals) einzusenden. Ich möchte es so haben:

Code: Select all

---the form---
input
input
input
submit button

--here show the response--
und der Client kann mehrere Übermittlungen senden und die Antwort wird wie oben angezeigt.
Außerdem erhalte ich diesen Fehler:

Code: Select all

/home/runner/costalica/index.js:87
})

SyntaxError: Unexpected end of input
Hier ist mein Code:

Code: Select all

const fetch = require('node-fetch');
const express = require('express');
const app = express();

// Parse request bodies
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
app.listen(3000);
app.get('/', (request, response) => {
let responseHTML = `


Login Form

CSRF Token:


Email:


Password:






`
response.send(responseHTML)
})

app.post('/', (req, res) => {
const {
csrf_token,
email,
password
} = req.body;

const data = `{
"_csrf_token": "${csrf_token}",
"email": "${email}",
"grant_type": "PWD",
"page": "AccountLogin",
"password": "${password}",
"recaptchaResponse": null,
"recaptchaSiteKey": null,
"step": "password",
"userDefaultedToPassword": false
}`;

let reqq = fetch('https://scrapeninja.p.rapidapi.com/scrape', {
method: 'POST',
headers: {
"Content-Type": "application/json",
"x-rapidapi-host": "HIDDEN",
"x-rapidapi-key": "HIDDEN"
},
body: JSON.stringify({
"url": "https://www.wayfair.com/a/account/authentication/login",
"method": "POST",
"headers": [
"authority: www.wayfair.com",
"accept: application/json",
"accept-language: en-US,en;q=0.9,ar;q=0.8",
"content-type: application/json",
"cookie: WFDC=DSM; CSNUtId=412864fc-a9f8-405c-8e19-aa56c086d7ea; ExCSNUtId=412864fc-a9f8-405c-8e19-aa56c086d7ea; vid=23e17d3a-64a8-81d9-9e3c-5c0227712302; SFSID=ed904601ed2bb197bcbf8d4f7643e8cc; canary=0; serverUAInfo=%7B%22browser%22%3A%22Google%20Chrome%22%2C%22browserVersion%22%3A114%2C%22OS%22%3A%22Windows%22%2C%22OSVersion%22%3A%2210%22%2C%22isMobile%22%3Afalse%2C%22isTablet%22%3Afalse%2C%22isTouch%22%3Afalse%7D; __px_jnfwwtr_5=disable; _pxhd=bytlkNG5QrgGWPC-1RImOXynN/cLl26bEP24UXFCHXT4He3u0Wh/mg3ui2mytf2n27lyNOZ85vc-lS7T36UIWw==:eLUfj4aK5RXvvmjDlAlCh8zSBU-3GpStZIT2o40y1HojI1D3p7xCH/aXJfZGO9TizTXeUiEBw5yVXmJFLaHL8fQYbI6z3V8rtEWJuu6zneo=; CSN_CSRF=c60cafb9043d3d61febb81a38d23ece011ecf59df63774332d8a1be0c401fe52; __cf_bm=OYuVFxcPmLDoUgBGpP7Nj78NQm5R.Jr7cK8ggEIR3Wo-1688764889-0-AejgIZQcufTBjfmr47Oi/soHVUy7JtWjQ0r9cSXFy8T+Rznig68CKCwIFVNcjBEv3llV7a66LjzOq8HiB9IQIac=; CSN=g_countryCode%3DUS%26g_zip%3D67346; CSNPersist=page_of_visit%3D5; _wf_fs_sample_user=true; ibb=1; CSNID=FCD55A66-8513-46C7-A656-C2C65BB20149; WFCS=CS9; g_state={\"i_p\":1688772129177,\"i_l\":1}; hideGoogleYolo=true",
"origin: https://www.wayfair.com",
"referer: https://www.wayfair.com/v/account/authentication/login?url=https%3A%2F%2Fwww.wayfair.com%2F&context=header_wayfair_my_account_menu",
"sec-ch-ua: \"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Microsoft Edge\";v=\"114\"",
"sec-ch-ua-mobile: ?0",
"sec-ch-ua-platform: \"Windows\"",
"sec-fetch-dest: empty",
"sec-fetch-mode: cors",
"sec-fetch-site: same-origin",
"sec-gpc: 1",
"user-agent: Mozilla/5.0 (Windows NT 10.0; Win64;  x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67",
"x-auth-caller-context: auth_main_page_context",
"x-csn-csrf-token: c60cafb9043d3d61febb81a38d23ece011ecf59df63774332d8a1be0c401fe52",
"x-parent-txid: I+F9OmSoge50vzFQLI6HAg==",
"x-requested-with: XMLHttpRequest"
],
"data": data
})
});
reqq.then(res => {
const json = res.json();
responseHTML += `${JSON.stringify(json, null, 2)}`
})

Top