I am making a node app that uses the npm library amfjs to decode a file. I am getting this error: (node:88188) UnhandledPromiseRejectionWarning: Error: No AMF3 type with ID 239
Here’s my code:
async function getDefpack(id) {
try {
var url = `https://ajcontent.akamaized.net/${version}/defPacks/${hashIt(id)}`
var response = await fetch(url).then(response => response.text())
if (response.includes("Access Denied")) {
log("That defPack doesn't exist.", "Doesn't Exist.")
}
else {
let rs = new Readable();
let decoder = new amfjs.AMFDecoder(rs);
rs.push(new Buffer.from(response)).toString()
rs.push(null)
var obj = decoder.decode();
delete obj.__class;
if (stringArray.hasOwnProperty(id)) {
for (var property in obj) {
var key = stringArray[id];
if (!stringsJSON.hasOwnProperty(obj[property][key])) continue;
obj[property].name = stringsJSON[obj[property][key]];
}
}
return JSON.stringify(obj, null, 2);
}
}
catch (err){
log("nnnn" + err)
}
}
The error points to my code let decoder = new amfjs.AMFDecoder(rs);
, though I am not familiar enough with this library to know what’s going on, so any help would be greatly appreciated!
at Object.fromId (node_modulesamfjslibtypes.js:168:15)
at AMFDecoder.deserialize (node_modulesamfjslibdecoder.js:58:24)
at AMFDecoder.decode (node_modulesamfjslibdecoder.js:53:19)