Comments (7)
but I haven't found any doc to describe it.
console.log
said it using util.format
.
util.format
said it using util.inspect
for object
.
util.inspect
is telling you depth
is 2
by default.
from help.
I'm happy to fix it
from help.
I'm happy to fix it
Shouldn't it just display issue?
Since REPL
or console.log
do not like browser provide a way to expend each property, the display of [Object]
still means it is a proper object
.
https://nodejs.org/api/util.html#utilinspectobject-showhidden-depth-colors
The maximum depth
of console.log
show is 2
.
import pug from 'pug'
const html = pug.render('p= data', {
data: {
string: 'example text',
object: { string: 'text 2', object: { string: 3 } } // not [Object]
}
})
console.log(html) // <p>[object Object]</p>
pug
is actually printing the object
using .toString
and that is expected result.
from help.
It has nothing to do with JSON.parse()
, as @climba03003 mentioned it's the documented behavior of console.log()
. You should first convert the data to a string with e.g. JSON.stringify()
, util.format()
, or a third party library.
from help.
Sounds reasonable, the default depthof
console.logis 2, that's why
{ string: 3 }` doesn't been shown, but I haven't found any doc to describe it.
from help.
In your code, you're correctly stringifying an object and then parsing it back into an object. However, when you pass _data to your Pug template, you're assigning the entire object to a variable called data. This is why you're seeing [object Object] in your view because data is an object, and Pug is displaying it as a string representation.
from help.
(This issue seems resolved)
from help.
Related Issues (20)
- Node process at VPSs terminates without error. HOT 2
- Need help with embedded API HOT 3
- Install Node.js with FIPS enabled HOT 8
- enable exception for the embedder example
- Is Node.js version 20.8.X officially supported on Windows server 2012 R2 ? HOT 4
- Error with first launch HOT 1
- Error building 22.2.0 (v8) on Debian 12 HOT 3
- Extendeing Buffer HOT 9
- use "yarn install" There are always errors βerror Error: incorrect data check at Zlib.zlibOnError [as onerror] (node:zlib:189:17)β HOT 2
- Emulating files with no writing to disk HOT 3
- Resolve promise synchronously HOT 4
- sqlite3 5.1.7 will not require or import on nodejs HOT 6
- How to use private keys persisted in the TPM with tpm2-openssl OpenSSL Provider
- Stop cpu profiling without SIGINT from pod HOT 1
- Can't read and write to target executable HOT 5
- Segmentation fault (core dumped) when run executable file HOT 2
- Help me i have problems with running npm HOT 2
- crypto.privateDecrypt throwing Error: error:0407109F:rsa routines:RSA_padding_check_PKCS1_type_2:pkcs decoding error HOT 4
- Node Js Website URL Change
- MSVC Deprecation on windows builds? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from help.