내가 원하는 것은 특정 페이지로 리다이렉트 할 때 req/res 오브젝트를 파일에 로깅하여 (나중에 어떤 오브젝트 값으로도 참조 할 수 있기 때문이다.) 그래서으로NodeJS의 파일에 req 객체 콜백 라우트를 쓰는 방법은 없습니까?
app.get("/route", function(req, res) {
res.render("route");
fs.writeFile('./data.json', JSON.stringify(req, null, 2) , 'utf-8', function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
위의 코드를 던지고 오류 :
나는이 시도TypeError: Converting circular structure to JSON at Object.Stringify (native)
내가 다른 일을해야 아무것도 있습니까? 어떤 도움을 주셔서 감사합니다. 미리 감사드립니다.
가능한 중복 사용 만 쿼리를 저장해야하는 경우
이 시도 [JSON.stringify, TypeError : 원형 구조체를 JSON으로 변환하지 않기] (https://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json) – juandemarco
왜 하시겠습니까? 전체 개체를 저장 하시겠습니까? 어떤 필드를 저장 하시겠습니까? – Tvde1
특히 당신을 위해이 답변을 고려해 보겠습니다 : https://stackoverflow.com/a/18354289/1053772 – juandemarco