'_path2.default.basename is not a function using convertapi in angular

I am trying to integrate the convertapi in my Angular 11 application using the following documentation

https://www.npmjs.com/package/convertapi

I need to convert the pdf's into images,

When I try to upload a file, I get

_path2.default.basename is not a function

Here is how I have implemented this in my component

Import

import ConvertAPI from 'convertapi';

Initiate

const convertapi = new ConvertAPI('my actual api-secret ');

And convert

convertapi.convert('jpg', { File: file }) //'file' is actual file object, also tried pdf url
      .then(function(result: any) {
      console.log(result)
})
.catch(function(e: any) {
      console.log(e.toString()); // this prints out the error message
});

Is there anything I am missing?



Solution 1:[1]

This library is a non module, please refer to this question on how to use it with Angular: Angular 2+ Import a Non Module into TS

This is the documentation: https://github.com/ConvertAPI/convertapi-js

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jonas