-
Notifications
You must be signed in to change notification settings - Fork 8
Description
I've found a bug for the /files route to show all the files found in the directory and i encountered a bug, it throws this error whenever i try to go to "localhost:3200/files". I've actually managed to fix it and i can provide the working code as well.
Error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:405:5)
at validateString (node:internal/validators:162:11)
at Object.join (node:path:429:7)
at LocalFiles.idToPath (C:\Users\gaby2\Desktop\filemanager-node-master\node_modules\wfs-local\lib\LocalFiles.js:203:44)
at LocalFiles. (C:\Users\gaby2\Desktop\filemanager-node-master\node_modules\wfs-local\lib\LocalFiles.js:48:35)
at Generator.next ()
at C:\Users\gaby2\Desktop\filemanager-node-master\node_modules\wfs-local\lib\LocalFiles.js:8:71
at new Promise ()
at __awaiter (C:\Users\gaby2\Desktop\filemanager-node-master\node_modules\wfs-local\lib\LocalFiles.js:4:12)
at LocalFiles.list (C:\Users\gaby2\Desktop\filemanager-node-master\node_modules\wfs-local\lib\LocalFiles.js:42:16) {
code: 'ERR_INVALID_ARG_TYPE'
}
Working code :
app.get("/files", async (req, res, next) => {
res.send(
await drive.list("/", {
skipFiles: false,
subFolders: false,
exclude: (a) => a.indexOf(".") === 0,
})
);
});