vendredi 5 avril 2019

How to send several parameters from server to js map

In my laravel 5.7 / jQuery 3 app I need to send several parameters from server

$retArray= ['error_code' => 0, 'message' => ''];

foreach( $requestData as $next_param_name ) {
    if( $next_param_name == 'customerAccountTypeValueArray' ) {
        $retArray['customerAccountTypeValueArray']= Customer::getCustomerAccountTypeValueArray(false);
    }
    if( $next_param_name == 'customerStatusValueArray' ) {
        $retArray['customerStatusValueArray']= Customer::getCustomerStatusValueArray(false);
    }
}

return response()->json( $retArray, 200);

and Array retArray has data like :

Array
(
    [error_code] => 0
    [message] => 
    [customerAccountTypeValueArray] => Array
        (
            [I] => Individual
            [B] => Business
        )

    [customerStatusValueArray] => Array
        (
            [A] => Active
            [I] => Inactive
            [N] => New
        )

)

But I got Javascript error :

Error in render: "TypeError: selectionsList.map is not a function" found in

with my JS code:

axios.post('/api/dashboard-settings', paramsArray) .then((response) => {

selectionsList= response.data.customerAccountTypeValueArray,
selectionsList.map((nextSelection, index) => {

looks like selectionsList is not array of elements, as I expected. Which is right way?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire