-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlegacy.js
More file actions
31 lines (26 loc) · 815 Bytes
/
Copy pathlegacy.js
File metadata and controls
31 lines (26 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Legacy v1 conversion example - XML to CSV
*
* This example shows how to use the legacy (v1.0.0 to v1.0.3) ConversionClient to convert a file.
*/
const ConversionClient = require('conversiontools/legacy');
// Get API token from environment or use directly
const apiToken = process.env.CONVERSION_TOOLS_API_TOKEN || 'your-api-token-here';
const config = {
type: 'convert.xml_to_csv',
options: {
filename: './test.xml',
timeout: 4000,
outputFilename: 'result.csv',
},
};
const convert = async () => {
try {
const conversionClient = new ConversionClient(apiToken);
const filename = await conversionClient.run(config.type, config.options);
console.log('File downloaded to', filename);
} catch (err) {
console.error('Conversion error', err.message);
}
};
convert();