Wednesday, 1 May 2019

Axios Request in a Laravel App returns UnexpectedValueException exception

I am using Axios in a Laravel app for a GET request, however for some reason the request is returning the exception: UnexpectedValueException with the message:

"The Response content must be a string or object implementing __toString(), "boolean" given."

The request is returning this exception, regardless of what I include in the response.

Switching out the Axios request for a jQuery request works just fine, so I am assuming it is an issue with the Axios library.

This request returns the exception:

axios.get(`/prospect/fetch`);

However this jQuery request works just fine:

$.get('/prospect/fetch');

Laravel fetch function:

public function fetch() {
    return response()->json([
        'collection' => Prospect::all()
    ]);
}

What is wrong with the Axios request?



from Axios Request in a Laravel App returns UnexpectedValueException exception

No comments:

Post a Comment