suchen

Heim  >  Fragen und Antworten  >  Hauptteil

Javascript – Ausnahmebehandlung in Express versprechen

sms_code(userInfo).then(function(data){
    return res.json(data);
})
.then(function(data){
    return res.json(data);
})
.catch(next);

Warum

catch(function(err){
    next(err)
})

kann mit

abgekürzt werden
.catch(next);
怪我咯怪我咯2827 Tage vor467

Antworte allen(2)Ich werde antworten

  • phpcn_u1582

    phpcn_u15822017-05-16 13:27:13

    catch(function(err){
        next(err)
    })
    

    等于

    catch(next)
    
    function next(err){
    
    }

    你说可以么?

    Antwort
    0
  • 阿神

    阿神2017-05-16 13:27:13

    setTimeout(function(){
        doSomeSth()
    },1000)
    
    setTimeout(doSomeSth,1000);
    
    

    Antwort
    0
  • StornierenAntwort