The development of koa2 web is confused and asks for advice.

I fumbled to do web development with koa2, and now I find that the front desk is unable to request data. I would like to ask what is unreasonable?

 controllers
    page.js
 models
    pageModel.js
 public
 routes
    index.js
 views
    page.ejs
 app.js

/ controllers/page.js

const config = require("../config")
const frontListNewsCenterModel = require("../models/frontListNewsCenter")

module.exports = async (ctx, next) => {
    const { companyNews, industryNews } = await frontListNewsCenterModel(ctx);
    console.log( companyNews )

    await ctx.render("frontListNewsCenter", {
        header: {
            title: "",
            javascript: config.javascript.concat("/js/jqpaginator.min.js", "/js/frontListNewsCenter.js"),
            style: config.style.concat("/css/frontListNewsCenter.css"),
        },
        newBanner: {
            imgSrc: "/images/newsbannenr.png",
        },
        tabNav: {
            items: [{
                cn: "",
                en: "Company news",
            }, {
                cn: "",
                en: "Industry information",
            }],
        },
        companyNews: companyNews,
        industryNews: industryNews,
    })
}

/ models/pageModel.js

const { getCompanyNewsList, getIndustryInfoList } = require("../config").service
const axios = require("axios")

module.exports = async (ctx, next) => {
    const page = ctx.query.page || "1"    // page
    const size = ctx.query.size || "10"   // size
    const role = ctx.query.role || "news" // role

    let companyNews = []
    let industryNews = []

    if (role === "news") {
        companyNews = await axios.get(getCompanyNewsList, {
            params: {
                page: page,
                size: size
            }
        })

        if (companyNews.data.code === "2000") {
            companyNews = companyNews.data.obj
        }
    }

    if (role === "industry") {
        industryNews = await axios.get(getIndustryInfoList, {
            params: {
                page: page,
                size: size
            }
        })

        if (industryNews.data.code === "2000") {
            industryNews = industryNews.data.obj
        }
    }

    return {
        companyNews,
        industryNews,
    }
}
Mar.04,2021

where can't get through


but the project already provides an interface

the backend has already provided an interface, so the front end can request it directly. What kind of requirements do you want to achieve when you add a layer of koa ?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eafa1b-48043.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eafa1b-48043.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?