«Undefined index: username in Magento/Customer/Controller/Ajax/Login.php on line 101»

getting ajax resonace {“errors”:true,“message”:“Invalid login or password.”}

i try to debug this issues…

go to vendor/magento/module-customer/Controller/Ajax/Login.php

for checking changes the code

} catch (EmailNotConfirmedException $e) {
        $response = [
            'errors' => true,
            'message' => $e->getMessage()
        ];
    } catch (InvalidEmailOrPasswordException $e) {
        $response = [
            'errors' => true,
            'message' => $e->getMessage()
        ];
    } catch (\Exception $e) {
        $response = [
            'errors' => true,
            'message' =>  __('Invalid login or password.')
        ];
    }

I removed the __(‘Invalid login or password.’)… to $e->getMessage() in } catch (\Exception $e) {

after change this code i get below mention error:

{“errors”:true,“message”:“Notice: Undefined index: username in /var/www/html/m2/vendor/magento/module-customer/Controller/Ajax/Login.php on line 101”}

My request Data in post method:

{login[username]: "roni_cost@example.com", login[password]: "roni_cost@example.com"}

How to fix this error… help me…

What exact code is on the problem line 101?

Issue in your ajax request data
$.ajax({
type: ‘post’,
url: ‘customer/ajax/login’,
loader:true,
dataType: “JSON”,
data: JSON.stringify({“username”:$(form).find(‘input[name=“username”]’).val(), “password”:$(form).find(‘input[name=“password”]’).val()}),