В моем приложении laravel 5.7 / jQuery 3 мне нужно отправить несколько параметров с сервера
$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);
и Array retArray имеет такие данные, как:
Array
(
[error_code] => 0
[message] =>
[customerAccountTypeValueArray] => Array
(
[I] => Individual
[B] => Business
)
[customerStatusValueArray] => Array
(
[A] => Active
[I] => Inactive
[N] => New
)
)
Но я получил ошибку Javascript:
Error in render: "TypeError: selectionsList.map is not a function" found in
с моим JS-кодом:
axios.post ('/ api / dashboard-settings', paramsArray)
.then ((ответ) => {
selectionsList= response.data.customerAccountTypeValueArray,
selectionsList.map((nextSelection, index) => {
похоже, что selectionsList не является массивом элементов, как я ожидал. Какой правильный путь?
Изменено:
Вот как я вижу данные с сервера в консоли браузера: https://imgur.com/a/jH6Juyo
и я установил это позже как параметр.
Спасибо!