gpt4 book ai didi

javascript - 类型错误 : Cannot read property 'charAt' of undefined

转载 作者:行者123 更新时间:2023-12-02 23:39:07 25 4
gpt4 key购买 nike

我收到带有以下代码的“TypeError”错误。

for(var i =0; i<60; i++) {
const fetch = require("node-fetch");
function postData() {
fetch('https://www.oneblockdown.it/index.php', {
method: 'POST',
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
'controller': 'auth',
'action': 'register',
'extension': 'obd',
'email': generateName1()+'@*******',
'password': '********',
'firstName': generateName1(),
'lastName': generateName2(),
'birthDate': '1992-6-11',
'sex': 'MALE',
'privacy[1]': '1',
'privacy[2]': '0',
'version': '100'
})
})
};


function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}

function generateName1(){
var name1 = ["Harry","Ross",
"Bruce","Cook","Carolyn","Morgan","Albert","Walker","Randy","Reed",
"Larry","Barnes","Lois","Wilson","Jesse","Campbell","Ernest","Rogers",
"Theresa","Patterson","Henry","Simmons","Michelle","Perry","Frank","Butler","Shirley","Brooks","Rachel","Edwards","Christopher","Perez",
"Thomas","Baker","Sara","Moore","Chris","Bailey","Roger","Johnson",
"Marilyn","Thompson","Anthony","Evans","Julie","Hall","Paula","Phillips","Annie","Hernandez","Dorothy","Murphy","Alice","Howard",
"Ruth","Jackson","Debra","Allen","Gerald","Harris","Raymond","Carter",
"Jacqueline","Torres","Joseph","Nelson","Carlos","Sanchez","Ralph","Clark","Jean","Alexander","Stephen","Roberts","Eric","Long","Amanda","Scott","Teresa","Diaz","Wanda","Thomas"];
var name = capFirst(name1[getRandomInt(0, name1.length + 1)]);

return name;
}
function generateName2(){

var name2 =[ "Anderson", "Ashwoon", "Aikin", "Bateman", "Bongard", "Bowers", "Boyd", "Cannon", "Cast", "Deitz", "Dewalt", "Ebner", "Frick", "Hancock", "Haworth", "Hesch", "Hoffman", "Kassing", "Knutson", "Lawless", "Lawicki", "Mccord", "McCormack", "Miller", "Myers", "Nugent", "Ortiz", "Orwig", "Ory", "Paiser", "Pak", "Pettigrew", "Quinn", "Quizoz", "Ramachandran", "Resnick", "Sagar", "Schickowski", "Schiebel", "Sellon", "Severson", "Shaffer", "Solberg", "Soloman", "Sonderling", "Soukup", "Soulis", "Stahl", "Sweeney", "Tandy", "Trebil", "Trusela", "Trussel", "Turco", "Uddin", "Uflan", "Ulrich", "Upson", "Vader", "Vail", "Valente", "Van Zandt", "Vanderpoel", "Ventotla", "Vogal", "Wagle", "Wagner", "Wakefield", "Weinstein", "Weiss", "Woo", "Yang", "Yates", "Yocum", "Zeaser", "Zeller", "Ziegler", "Bauer", "Baxster", "Casal", "Cataldi", "Caswell", "Celedon", "Chambers", "Chapman", "Christensen", "Darnell", "Davidson", "Davis", "DeLorenzo", "Dinkins", "Doran", "Dugelman", "Dugan", "Duffman", "Eastman", "Ferro", "Ferry", "Fletcher", "Fietzer", "Hylan", "Hydinger", "Illingsworth", "Ingram", "Irwin", "Jagtap", "Jenson", "Johnson", "Johnsen", "Jones", "Jurgenson", "Kalleg", "Kaskel", "Keller", "Leisinger", "LePage", "Lewis", "Linde", "Lulloff", "Maki", "Martin", "McGinnis", "Mills", "Moody",
"Moore", "Napier", "Nelson", "Norquist", "Nuttle", "Olson",
"Ostrander",
"Reamer", "Reardon", "Reyes", "Rice", "Ripka", "Roberts", "Rogers",
"Root",
"Sandstrom", "Sawyer", "Schlicht", "Schmitt", "Schwager", "Schutz",
"Schuster", "Tapia", "Thompson", "Tiernan", "Tisler" ];

var name12 = capFirst(name2[getRandomInt(0, name2.length + 1)]);
return name12;``
}

postData();
}

以下是完整的错误:

TypeError: Cannot read property 'charAt' of undefined at capFirst (c:\Users\Billy\nodejs\OBDnew (1).js:28:23) at generateName1 (c:\Users\Billy\nodejs\OBDnew (1).js:44:20) at postData (c:\Users\Billy\nodejs\OBDnew (1).js:13:26) at Object. (c:\Users\Billy\nodejs\OBDnew (1).js:56:5) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3) at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)

最佳答案

一切正常。看看:

function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}

function generateName1(){
var name1 = ["Harry","Ross",
"Bruce","Cook","Carolyn","Morgan","Albert","Walker","Randy","Reed",
"Larry","Barnes","Lois","Wilson","Jesse","Campbell","Ernest","Rogers",
"Theresa","Patterson","Henry","Simmons","Michelle","Perry","Frank","Butler","Shirley","Brooks","Rachel","Edwards","Christopher","Perez",
"Thomas","Baker","Sara","Moore","Chris","Bailey","Roger","Johnson",
"Marilyn","Thompson","Anthony","Evans","Julie","Hall","Paula","Phillips","Annie","Hernandez","Dorothy","Murphy","Alice","Howard",
"Ruth","Jackson","Debra","Allen","Gerald","Harris","Raymond","Carter",
"Jacqueline","Torres","Joseph","Nelson","Carlos","Sanchez","Ralph","Clark","Jean","Alexander","Stephen","Roberts","Eric","Long","Amanda","Scott","Teresa","Diaz","Wanda","Thomas"];
var name = capFirst(name1[getRandomInt(0, name1.length + 1)]);

return name;
}
function generateName2(){

var name2 =[ "Anderson", "Ashwoon", "Aikin", "Bateman", "Bongard", "Bowers", "Boyd", "Cannon", "Cast", "Deitz", "Dewalt", "Ebner", "Frick", "Hancock", "Haworth", "Hesch", "Hoffman", "Kassing", "Knutson", "Lawless", "Lawicki", "Mccord", "McCormack", "Miller", "Myers", "Nugent", "Ortiz", "Orwig", "Ory", "Paiser", "Pak", "Pettigrew", "Quinn", "Quizoz", "Ramachandran", "Resnick", "Sagar", "Schickowski", "Schiebel", "Sellon", "Severson", "Shaffer", "Solberg", "Soloman", "Sonderling", "Soukup", "Soulis", "Stahl", "Sweeney", "Tandy", "Trebil", "Trusela", "Trussel", "Turco", "Uddin", "Uflan", "Ulrich", "Upson", "Vader", "Vail", "Valente", "Van Zandt", "Vanderpoel", "Ventotla", "Vogal", "Wagle", "Wagner", "Wakefield", "Weinstein", "Weiss", "Woo", "Yang", "Yates", "Yocum", "Zeaser", "Zeller", "Ziegler", "Bauer", "Baxster", "Casal", "Cataldi", "Caswell", "Celedon", "Chambers", "Chapman", "Christensen", "Darnell", "Davidson", "Davis", "DeLorenzo", "Dinkins", "Doran", "Dugelman", "Dugan", "Duffman", "Eastman", "Ferro", "Ferry", "Fletcher", "Fietzer", "Hylan", "Hydinger", "Illingsworth", "Ingram", "Irwin", "Jagtap", "Jenson", "Johnson", "Johnsen", "Jones", "Jurgenson", "Kalleg", "Kaskel", "Keller", "Leisinger", "LePage", "Lewis", "Linde", "Lulloff", "Maki", "Martin", "McGinnis", "Mills", "Moody",
"Moore", "Napier", "Nelson", "Norquist", "Nuttle", "Olson",
"Ostrander",
"Reamer", "Reardon", "Reyes", "Rice", "Ripka", "Roberts", "Rogers",
"Root",
"Sandstrom", "Sawyer", "Schlicht", "Schmitt", "Schwager", "Schutz",
"Schuster", "Tapia", "Thompson", "Tiernan", "Tisler" ];

var name12 = capFirst(name2[getRandomInt(0, name2.length + 1)]);
return name12;``
}


console.log( generateName2() )

关于javascript - 类型错误 : Cannot read property 'charAt' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56156496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com