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.

requestToken() never ends

See original GitHub issue

Hi,

First, thanks for your library. It works almost like a charm! šŸ‘ But I have a small issue and I canā€™t find a way to fix it (Iā€™m a kind of newbie)ā€¦

Using your own example (for testing purpose), Iā€™ve set my /sendtoken route, but the request never ends: the email containing the token is sent, the token worksā€¦ but - using my example - I canā€™t console.log('end here') or diplay sent.

I tried a few things without any success. It seems to miss a next(), but you do not use it on your docs.

Do you have an idea whatā€™s going on?

Thanks a lot.

const express = require('express')
const passwordless = require('passwordless')
const router = express.Router({ mergeParams: true })

var users = [
  { id: '1', email: 'myemail1@gmail.com' },
  { id: '2', email: 'myemail2@gmail.com' }
]

// POST route
router.post(
  '/sendtoken',
  function(req, res, next) {
    console.log('enter here') // <-- I can console.log() this message
    next()
  },
  passwordless.requestToken(function(user, delivery, callback) {
    console.log('inside requesttoken') // <-- I can console.log() this message
    for (var i = users.length - 1; i >= 0; i--) {
      if (users[i].email === user.toLowerCase()) {
        return callback(null, users[i].id)
      }
    }
    callback(null, null)
  }),
  function(req, res) {
    console.log('end here') // <-- I CANNOT console.log() this message
    res.sent('sent')
  }
)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fraunoscommented, Dec 3, 2018

I had the same problem - had no callback() cast at the end of delivery

0reactions
AmrKafinacommented, Nov 26, 2019

If anyone runs into this, make sure you call callback() at the end of your delivery method!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Axios - C# WebAPI request token fails without a server ...
Finally found my answer. It turns out I had not enabled CORS in my WebAPI back-end for the /token endpoint. The way I...
Read more >
Troubleshooting CloudFormation - AWS Documentation
If AWS CloudFormation fails to create, update, or delete your stack, you can view error messages or logs to help you learn more...
Read more >
Obtaining Access Tokens using 3-legged OAuth flow
Create a request for a consumer application to obtain a request token. Have the user authenticate, and send the consumer application a request...
Read more >
(solved) Java Oauth request_token flow example, without ...
Once you get your request token are you able to poste a tweet to twitter using this code? Can you put your code...
Read more >
Prevent Cross-Site Request Forgery (XSRF/CSRF) attacks in ...
A best practice is to never change state on a GET request. ... The antiforgery cookie token and request token do not match....
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