如何在没有功能破坏的情况下处理404?

时间:2014-03-29 22:23:26

标签: javascript jquery fullcontact

基本上,我有一系列电子邮件(attemptsArray),我使用FullContact的API查找。

attemptsArray.forEach(function(attempt) {
    $.fullcontact.emailLookup(APIKEY, attempt, function(obj) {
        attemptsMade = attemptsMade + 1
        console.log(attemptsMade);
        console.log('Looking up '+attempt+' ...This is attempt number'+attemptsMade)

        if (obj.status == 200) {
            var score = obj.likelihood;
            console.log('Matched with a '+score+' likelihood')
            correctAttempts.push(obj);
        };
    });
});

但是,如果返回404(即电子邮件不存在),则不会增加attemptsMade。有没有办法确保这种情况发生?我尝试过做if (obj.status == 404)但也不行。

0 个答案:

没有答案