My initial question got marked as a duplicate for a completely unrelated question that has absolutely nothing in common with my question, so I’m reposting this with some clarifications that should hopefully make it clearer what I want to do.
Suppose I have a file on a server that is NOT my server:
https://example.com/names.txt
Is there a function such that I can read this file as a String or as a Buffer?
The obvious solution would be to download the file into a temporary directory, read its contents, then delete it, but this is very slow and takes many lines of code. Is there a cleaner way to do this?
>Solution :
You’d have to make a request to that server for that file. (e.g. a GET request) using the module of your choice.
Making a request with the HTTP module
Note: in the example, d in the on('data', ...) callback will be what you want.