简体   繁体   中英

how to print object from RESTful web service using jade

I am trying to print something from a RESTful web service but it comes out like this.

{
"
i
d
"
:
"
e
9
7
f
e
6
2
0
-
1
6
5
6
-
1
1
e
5
-
9
5
5
e
-
2
7
1
a
3
8
c
2
6
f
3
2
"
,
"
d
a
t
a
"
:
{
"
n
a
m
e
"
:
"
d
e
p
o
s
i
t
c
h
e
q
u
e
"
}

What I am hoping for instead is something like this:

1. deposit cheque

I am not too sure if it is a problem with my java script or jade but here are both.

router.get('/', function(req, res, next) {

    request({
    url: url, //URL to hit
    qs: {from: 'blog example', time: +new Date()}, //Query string data
    method: 'GET', //Specify the method  
    headers: { //We can define headers too
        'Content-Type': 'MyContentType',
        'Custom-Header': 'Custom Value'
    }
    }, function(error, response, body){
      if(error) {
          res.render('index', { title: 'Express', data: []});
      } else {
          res.render('index', { title: 'Express', data: body });
      }

});

Here is my jade:

ul
  for item in data
    li= item
  else
    li sorry, no items!

How can I modify this to print out what I want?

而是尝试res.render('index', { title: 'Express', data: JSON.stringify(body) });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM