이재용

결과값을 res.json 해주는 코드 추가

1 var user=require("../user/userinfo") 1 var user=require("../user/userinfo")
2 var express = require('express'); 2 var express = require('express');
3 +const search = require("../api/api");
3 var app = express.Router(); 4 var app = express.Router();
4 app.get('/', function(req, res) { 5 app.get('/', function(req, res) {
5 res.render('main', { title: 'R U TROLL?' }); 6 res.render('main', { title: 'R U TROLL?' });
6 }); 7 });
7 8
8 -app.get('/search/:username/', function(req, res){ 9 +app.get('/api/search/:username/', function(req, res){
9 - var name=req.params.username 10 + var name=req.params.username;
10 - user.userInfo(name) 11 + user.userInfo(name,function(result){
12 + console.log(result);
13 + res.json(result);
14 + });
11 }); 15 });
12 16
13 module.exports=app; 17 module.exports=app;
...\ No newline at end of file ...\ No newline at end of file
......