INNER CODE UNIT · JavaScript

fetchCourse

naihe138/GraphQL-demo · src/controllers/course.js:23

const fetchCourse = async (ctx, next) => {
  const courses = await Course.find({})

  if (courses.length) {
    ctx.body = {
      success: true,
      data: courses
    }
  } else {
    ctx.body = {
      success: false
    }
  }
}

module.exports = {
  saveCourse,
  fetchCourse

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…