I have a soap xml api project but I can't use soap module.
enter image description here`
error - TypeError: Cannot read properties of undefined (reading 'create')
at new HttpClient (C:\Users\Datch\Masaüstü\sigorateklifim-github\node_modules\soap\lib\http.js:40:59)
at Object.open_wsdl (C:\Users\Datch\Masaüstü\sigorateklifim-github\node_modules\soap\lib\wsdl\index.js:1270:48)
at openWsdl (C:\Users\Datch\Masaüstü\sigorateklifim-github\node_modules\soap\lib\soap.js:70:16)
at C:\Users\Datch\Masaüstü\sigorateklifim-github\node_modules\soap\lib\soap.js:48:13
at _requestWSDL (C:\Users\Datch\Masaüstü\sigorateklifim-github\node_modules\soap\lib\soap.js:76:9)
at Object.createClient (C:\Users\Datch\Masaüstü\sigorateklifim-github\node_modules\soap\lib\soap.js:94:5)
at handler (webpack-internal:///(api)/./src/pages/api/identity.js:16:39)
at Object.apiResolver (C:\Users\Datch\Masaüstü\sigorateklifim-github\node_modules\next\dist\server\api-utils\node.js:367:15)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
page: '/api/identity'
}
`
I am trying to get a part of a string.
let someValue = 'basic jkclwkjkvhrvhkuirhiehvyrbuyrbevnervnhrev';
let getSubstringValue = someValue.substring(6);
But, in my node JS server gives,
TypeError: Cannot read properties of undefined (reading 'substring')
Also used 'substr' using 'this answer'. But it also gave this 'TypeError: Cannot read properties of undefined (reading 'substr')' error.
Can you debug someValue if it is a string?
If it's undefined, you get the error
TypeError: Cannot read properties of undefined
Simple example of substring:
exampleVal = 'test';
// remove the first character
exampleVal = exampleVal.substring(1);
// show results (output is 'est')
console.log(exampleVal);
// example for if exampleVal is undefined
let exampleVar = undefined;
exampleVar = exampleVar.substring(1);
console.log(exampleVar);
// error is thrown
// TypeError: Cannot read properties of undefined (reading 'substring')
I am getting error while executing following function in whatsapp web
Function:
const data = window.Store.Presence.find(chatId);
Error:
/home/sariful/Public/whatappApi/files/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
^
Error: Evaluation failed: Error: gadd called without an id attr (id)
at p.gadd (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:71:532289)
at https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:71:653775
at Generator.next (<anonymous>)
at t (https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65356)
at s (https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65567)
at https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65626
at Y (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:31:99298)
at new y (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:31:91865)
at https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65507
at p._find (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:71:653867)
at ExecutionContext._evaluateInternal (/home/sariful/Public/whatappApi/files/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ExecutionContext.evaluate (/home/sariful/Public/whatappApi/files/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
I have been using pdf-merger-js to merge PDF files for a while now. I have used it with PDF files I have generated from HTML files and with PDF files I did not create.
Then I started getting the error:
Uncaught TypeError: Cannot read property 'compressed' of undefined
and the merger would fail. I tried different versions of node with the same results. The version that has been working is node v12.19.1.
/* /path/to/project/mpdf.js */
const PDFMerger = require('pdf-merger-js');
const path = require('path');
(async () => {
try {
const pdfs = ['pdf1.pdf','pdf2.pdf','pdf3.pdf','pdf4.pdf','pdf5.pdf'];
const merger = new PDFMerger();
pdfs.map(f => path.resolve(__dirname, "subfolder", f)
.forEach(pdf => merger.add(pdf));
//^^^Error occurs on this line
await merger.save('all-merged.pdf');
} catch( err ) {
console.log( err );
}
})();
Has any of you worked with pdf-merger-js and, have you encountered the above error? If so, how did you resolve the error?
Stack Trace
TypeError: Cannot read property 'compressed' of undefined
at parseObject (/path/to/project/node_modules/pdfjs/lib/object/reference.js:81:15)
at PDFReference.get [as object] (/path/to/project/node_modules/pdfjs/lib/object/reference.js:15:17)
at new ExternalDocument (/path/to/project/node_modules/pdfjs/lib/external.js:20:42)
at PDFMerger._addEntireDocument (/path/to/project/node_modules/pdf-merger-js/index.js:29:15)
at PDFMerger.add (/path/to/project/node_modules/pdf-merger-js/index.js:11:12)
at /path/to/project/app3.js:10:34
at Array.forEach (<anonymous>)
at /path/to/project/app3.js:10:12
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Update
I have encountered another set of PDF files that are throwing a different error on the same line:
TypeError: Cannot read property 'object' of undefined
at new ExternalDocument (/path/to/project/node_modules/pdfjs/lib/external.js:20:42)
at PDFMerger._addEntireDocument (/path/to/project/node_modules/pdf-merger-js/index.js:29:15)
at PDFMerger.add (/path/to/project/node_modules/pdf-merger-js/index.js:11:12)
at /path/to/project/app3.js:10:34
at Array.forEach (<anonymous>)
at /path/to/project/app3.js:10:12
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I got the same error whenever I used compressed PDFs for merging. Seems to be a bug in the underlying pdfjs library according to a Github issue in the pdf-merger-js repository.
Not the kind of answer I was looking for ....
If you flatten the files prior to merging them then the merging works fine. This seems to resolve the two errors I encountered.
I am using pdf-flatten just before merging as follows:
const fsp = require('fs').promises;
const flattener = require('pdf-flatten');
//....
const pdfs = ['pdf1.pdf','pdf2.pdf','pdf3.pdf','pdf4.pdf','pdf5.pdf'];
for(pdf of pdfs) {
const pdfB = await fsp.readFile(path.resolve(__dirname,"subfolder", pdf));
const pdfFlat = await flattener.flatten(pdfB, {density: 300});
await fsp.writeFile(path.resolve(__dirname,"subfolder", `flattened_${pdf}`), pdfFlat);
}
//....merge the flattened files:
//.... pdfs.map(p => `flattened_${p}`).....
_http_outgoing.js:299
value = value.replace(/[\r\n]+[ \t]*/g, '');
^
TypeError: undefined is not a function
at storeHeader (_http_outgoing.js:299:19)
at ClientRequest.OutgoingMessage._storeHeader (_http_outgoing.js:225:9)
at ClientRequest._implicitHeader (_http_client.js:184:8)
at ClientRequest.OutgoingMessage.end (_http_outgoing.js:513:10)
at createRequest (/root/.nvm/v0.11.13/lib/node_modules/ari-client/node_modules/swagger-client/node_modules/shred/lib/shred/request.js:532:16)
at new Request (/root/.nvm/v0.11.13/lib/node_modules/ari-client/node_modules/swagger-client/node_modules/shred/lib/shred/request.js:79:3)
at Object.Shred.request (/root/.nvm/v0.11.13/lib/node_modules/ari-client/node_modules/swagger-client/node_modules/shred/lib/shred.js:47:12)
at ShredHttpClient.execute (/root/.nvm/v0.11.13/lib/node_modules/ari-client/node_modules/swagger-client/lib/swagger.js:1314:21)
at SwaggerHttp.execute (/root/.nvm/v0.11.13/lib/node_modules/ari-client/node_modules/swagger-client/lib/swagger.js:1134:34)
at new SwaggerRequest (/root/.nvm/v0.11.13/lib/node_modules/ari-client/node_modules/swagger-client/lib/swagger.js:1099:27)