question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having a function for lookup seems to only work for the first request

See original GitHub issue

I “consoled” the block about the lookup option being a function:

    if (typeof(opts.lookup) === 'function') {
      console.log('1:' + opts.lookup);
      middleware = function (middleware, req, res, next) {
        console.log('2:' + opts.lookup);
        return opts.lookup(req, res, opts, function () {
          console.log('3:' + opts.lookup);
          return middleware(req, res, next)
        })
      }.bind(this, middleware)
    }

Then I booted the server:

Tue Sep 29 2015 12:38:06 GMT-0400 (EDT): 1:function (req, res, opts, next) {
      if (req.body && req.body.uuid) {
        opts.lookup = ['body.uuid', 'params.uid'];
      } else {
        opts.lookup = ['connection.remoteAddress', 'params.uid'];
        opts.total = 100;
      }
      return next();
    } 

Then I ran the first request:

2:function (req, res, opts, next) {
      if (req.body && req.body.uuid) {
        opts.lookup = ['body.uuid', 'params.uid'];
      } else {
        opts.lookup = ['connection.remoteAddress', 'params.uid'];
        opts.total = 100;
      }
      return next();
    } 
3:connection.remoteAddress,params.uid 

Then I ran the second request:

2:connection.remoteAddress,params.uid 
Tue Sep 29 2015 12:38:23 GMT-0400 (EDT): TypeError: Property 'lookup' of object #<Object> is not a function

Notice the second go console log 2 has been updated to what was console log 3’s.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
v-katcommented, Oct 7, 2016

New release please @ded

2reactions
nickdaughertycommented, Jul 19, 2017

Just ran into this too, any word on a new release @ded?

Read more comments on GitHub >

github_iconTop Results From Across the Web

LOOKUP function - Microsoft Support
How to use the LOOKUP function in Excel to search in a single row or column and find a value from the same...
Read more >
6 Reasons Why Your VLOOKUP is Not Working - Ablebits
The VLOOKUP function can only return one record. It will return the first record that matches the value you looked for. If your...
Read more >
LOOKUP FUNCTION ANNOYANCES - Excel ... - O'Reilly
The first function you can use to find a value in a worksheet is the LOOKUP() function. Basically, the LOOKUP() function identifies a...
Read more >
Find the Matching Value When the Lookup Value Is Not on the ...
This article shows you how to find matching value when the lookup value is not on the first column of the table array....
Read more >
Excel LOOKUP Function - Xelplus - Leila Gharani
Excel has many functions capable of performing lookups: VLOOKUP, ... However, the function that started it all was the original LOOKUP ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found