Skip to content

FormData

Stefan Stoichev edited this page Nov 1, 2021 · 1 revision

The package expose a special class QlikFormData. This class is to be used with specific SaaS APIs in NodeJS environment.

Some SaaS endpoints (like POST /themes) require the data to be passes as FormData.

Browsers have built-in form data which can be used directly but NodeJS dont have native method for this. Because of this when in Node we can use QlikFormData class

import fs from "fs";
import { QlikFormData } from "qlik-rest-api";

const saas = new QlikSaaSClient(saasConfig);

// read the theme zip file
const theme = fs.readFileSync("path/to/myTheme.zip");

// new instance of QlikFormData class
const fd = new QlikFormData();

// add "data" like tags
fd.append("data", JSON.stringify({}));
// add "file" - the zip file and the name
fd.append("file", theme, "myTheme.zip");

// upload new theme
const newTheme = await saas.Post(`themes`, fd.getData, fd.getHeaders);
Clone this wiki locally