Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

{"statusCode":400,"error":"Bad Request","message":"Unexpected token o in JSON at position 1"}


   	var data = {
            "username": login,
            "password": password,
            "passwordAgain": password
    };

    if (password.length <= 5 || login.length <= 3)
        throw new Error("Password / Username to short !");


    console.log(`${SERVER_URL}/register`);
    const response = await fetch(`${SERVER_URL}/register`,{
        method:'POST',
        headers:{ 'content-type': 'application/json' },
        body: data // < ===== Error from here ! Change it to JSON.stringify(data)
    });

    const body = await response.text();

    const $ = cheerio.load(body);
 
PREVIOUS NEXT
Tagged: #token #JSON #position
ADD COMMENT
Topic
Name
7+8 =