TypeError: markdown is not a function when the function is being imported from another folder

I am Working on a project which has the following file structure |—->controller | |___ … Read more TypeError: markdown is not a function when the function is being imported from another folder

I am Working on a project which has the following file structure

   |---->controller
   |    |___ file.js
   |    |___ mardown.js
   |
   |---->routes
        |____ routes.js  

I have a function named markdown written in the file markdown.js

Code in markdown.js is as follows

module.exports.markdown =  (html)=>{
       // Some code
       
      
      // return statement
       return value;
}

This markdown is being called in the routes.js file

Code in routes.js is as follows

const express = require('express');
const router = express.Router();
const markdown = require('../controller/markdown');


router.post("/upload" , cpUpload , async (req , res)=>{
    console.log(req.body);
    let markdowndData = await markdown(req.body.markdown);
    console.log(markdowndData);
    res.send('ok');

});

Basically I am trying to call the markdown function in the post route
but am getting an error

The following image is that of the error
error image

Source: JavaSript – Stack Overflow



Leave a Reply

Your email address will not be published. Required fields are marked *