It is not recommended to limit reads on secondaries.
You always connect to all servers. If you have one on port 27017 and one on 27018 the connection string looks like:
const url = 'mongodb://localhost:27017,localhost:27018/myproject?replicaSet=foo'
MongoClient.connect(url, function(err, db) {
//...
})
(But a replica set should have an odd number of members)
You can use the connection options to define your read preferences:
const {MongoClient, ReadPreference} = require('mongodb')
const url = 'mongodb://localhost:27017,localhost:27018,localhost:27019/myproject'
MongoClient.connect(url, {
replicaSet: 'foo',
readPreference: ReadPreference.SECONDARY_PREFERRED
}, function(err, db) {
//...
})