It's just not possible.
React native + Laravel. Problem with GET method
Hello everyone,
This is my first topic on the forum.| I have problem with React Native (Windows+Android Studio)+ Laravel(WSL) stack. When i call get to endpoint sometimes the last character ("]") disappears.
Like this
[ { "id": 1, "brand": "reprehenderit", "model": "animi", "year": "1988-12-23", "mileage": 9524, "vin_number": "accusantium", "client": { "id": 7, "name": "Terrence Reynolds", "surname": "Prof. Evelyn Bins Jr.", "email": "[email protected]", "phonenumber": 13234372651 }, "archive_service": [ { "id": 3, "description": "Reiciendis vero asperiores esse. Sed fuga sit neque est. Architecto ea recusandae ex quae placeat possimus.", "price": "27883.68", "bruttoprice": 1, "register_date": "2024-09-23", "start_date": "2025-02-02", "done_date": "2025-05-05", "end_date": "2025-08-25", "status": "new", "created_at": "2024-12-12T19:50:12.000000Z", "updated_at": "2024-12-12T19:50:12.000000Z" }, { "id": 4, "description": "Nisi dolores saepe optio aut porro consequuntur. Dolores sint corporis et officia et. Quo voluptas culpa ex illo et aut quam.", "price": "85.75", "bruttoprice": 0, "register_date": "2024-11-03", "start_date": "2025-02-11", "done_date": "2025-05-04", "end_date": "2025-08-27", "status": "new", "created_at": "2024-12-12T19:50:12.000000Z", "updated_at": "2024-12-12T19:50:12.000000Z" } ], "services": [ { "id": 2, "description": "Dicta ratione minima sit culpa et. Dolor ea nostrum quo qui at deleniti. Est doloremque consequatur maxime ea consectetur architecto ad qui.", "price": "231769.71", "bruttoprice": 0, "register_date": "2024-11-16", "start_date": "2025-02-28", "done_date": "2025-05-06", "end_date": "2025-08-11", "status": "new", "created_at": "2024-12-12T19:50:12.000000Z", "updated_at": "2024-12-12T19:50:12.000000Z" }, { "id": 5, "description": "Pariatur voluptatibus non ut aut ex. Voluptatem corporis est est molestiae dolorum consectetur. Labore fugit tenetur et quasi.", "price": "784677721.22", "bruttoprice": 1, "register_date": "2024-09-26", "start_date": "2025-02-27", "done_date": "2025-05-12", "end_date": "2025-08-11", "status": "new", "created_at": "2024-12-12T19:50:12.000000Z", "updated_at": "2024-12-12T19:50:12.000000Z" }, { "id": 7, "description": "Excepturi ipsam doloremque vitae repudiandae nam voluptatem velit qui. Ad sit est ut sint a. Assumenda sint illum impedit et voluptas.", "price": "171322.93", "bruttoprice": 0, "register_date": "2024-10-07", "start_date": "2025-03-08", "done_date": "2025-04-23", "end_date": "2025-08-05", "status": "new", "created_at": "2024-12-12T19:50:12.000000Z", "updated_at": "2024-12-12T19:50:12.000000Z" } ] }
At start we have "[" and after i call randomly times API endpoint (sometimes 1, sometimes 5) i get data without closed "]".
I log server Side and data sended to front is ok
This is my axios config import Axios from 'axios'; import * as SecureStore from 'expo-secure-store';
const axios = Axios.create({ baseURL: process.env.EXPO_PUBLIC_BACKEND_URL, timeout: 15000, responseType: 'json', headers: { 'Content-Type': 'application/json', }, });
axios.interceptors.request.use(async function (config) {
const storedUser = await SecureStore.getItemAsync('user');
if (storedUser) {
const user = JSON.parse(storedUser);
if (user.token) {
if (!config.headers.Authorization) {
config.headers.Authorization = Bearer ${user.token};
}
}
}
return config;
}, function (error) {
return Promise.reject(error);
});
export default axios;
And function to get data async function getAllCars() { try { const response = await axios.get("/cars");
console.log("OK");
console.log(response.data);
setData(response.data);
} catch (error) {
console.error("Error fetching cars:", error.message);
}
}
The code may look not very professional (I'm just learning). Me and three people who tried to help don't know the solution
Please or to participate in this conversation.