Answer the question
In order to leave comments, you need to log in
How to get a response in the form of an html page for a post request?
Good afternoon, guys, I use node-fetch and make a request to the site page, namely, I make a request for authorization, everything is sent normally, etc., but the response (in the network in the developer console in the browser) is issued in the form of html and not json.
Here is part of my code when responding as json
.then((res) => {
console.log(res);
console.log("___________________________________");
console.log(res.text());
return res.json();
})
.then((json) => {
console.log(json);
console.log("___________________________________");
})
Answer the question
In order to leave comments, you need to log in
Usually, authorization returns an error 401 on error, if this is the case for you, then node-fetch allows the following (code from the docks)
if authorization does not give an error on error, but returns stupidly Html (200), then html will have to be parsed in order to find out whether an error has occurred or not .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question