liuyu %!s(int64=5) %!d(string=hai) anos
pai
achega
b14ae24d81
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      app/service/news.js

+ 4 - 3
app/service/news.js

@@ -15,6 +15,7 @@ class NewsService extends CrudService {
 
   async fetch({ id }) {
     const news = await this.model.findById(id);
+    const newdata = { ...JSON.parse(JSON.stringify(news)) };
     if (news) {
       const url = 'http://127.0.0.1:9999/api/auth/user/' + news.uid;
       const user = await this.ctx.curl(url, {
@@ -24,11 +25,11 @@ class NewsService extends CrudService {
         },
         dataType: 'json',
       });
-      if (user.data.name) {
-        news.uname = user.data.name;
+      if (user.data.errcode === 0) {
+        newdata.uname = user.data.data.name;
       }
     }
-    return news;
+    return newdata;
   }
 
 }