const express = require('express');
const bodyParser = require('body-parser');
require('body-parser-xml')(bodyParser);
My code is ES6 module(import) , I don't know how to transform the above code to ES6 code .
import express from "express";
import * as bodyParser from 'body-parser';
import * as bodyParserXml from 'body-parser-xml';
bodyParserXml(bodyParser);
app.use(bodyParserXml());
the errors like these as following , Apr 18 09:12:55 PM file:///opt/render/project/src/app.js:8 Apr 18 09:12:55 PM bodyParserXml(bodyParser); Apr 18 09:12:55 PM TypeError: bodyParserXml is not a function
the solution according this article . translation into es6 import
According to the library creator you shoud try this:
import bodyParser from 'body-parser';
import bodyParserXml from 'body-parser-xml';
bodyParserXml(bodyParser);
app.use(bodyParser.xml());