Có cách nào khác ngoài cách lưu trữ một biến global.my_url
-
Mình hay làm thế này
app.listen(port, function () { global.my_url = "http://localhost:"+port; //https://nodetpl-ok1.herokuapp.com/ //global.my_url="https://nodetpl-ok1.herokuapp.com"; console.log('server listen at %s', global.my_url); });
Có cách nào khác không, để tự động lấy ?
-
tao mot file config rieng roi co the export no ra de sang day goi.
con khong thi viet o tren file package.json ay
-
@Thuc-Nguyen-tan Bạn thử module này của mình viết xem sao? Ngoài việc lưu trữ ra, nó còn hỗ trợ tìm kiếm theo key hoặc value, theo dõi giá trị thay đổi của biến, ...
https://nodejs.vn/topic/1000/kiper-thư-viện-theo-dõi-và-lưu-trữ-các-objects-trong-ứng-dụng-nodejs