and according to the request payload in my browser it is sending the prompt data but the validation in laravel is telling me that "prompt is required". Here is my validation
@ruthback thanks but I've tried it both ways already and as I said the request payload clearly shows the prompt being sent to the api endpoint, this is the request payload as per Chrome.
{headers: {}, data: {prompt: "a mouse riding a cat chasing a dog"}}
data: {prompt: "a mouse riding a cat chasing a dog"}
headers: {}
@aarontharker I don't think you need to specify the data property, that's probably what is tripping Laravel off because it's reading data while it's expecting prompt which is inside data. You could try to specify "data.prompt" in your validation as well, though I'm not entirely sure this will work?
@aarontharker Here I would guess it's because the response method returns a full response object, but Axios by default will expect JSON data. You can try to use the json method on the response object:
{
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest",
"X-XSRF-TOKEN": "eyJpdiI6ImtMY2ZpODFHbUFoOUM4S1F3NEVlT2c9PSIsInZhbHVlIjoid0syOHRaNnhnRnU3akkxZ1loZkUxNkdIQW1YblgzUmNPaHN4NHFmTWlRYnZaa1lsaFA1SkQ0Tk9uR2JXQU5BcG02VXY3MXBwSitYT0g5MzJ0OXNXb2pCUVFHdXlSWEhOMTVZNHJ0em1uZE1NdERmMkdyOGVOTGdtZ2ZtbU9lcXQiLCJtYWMiOiIzMTVlODhkOGFjMWRhZDYyMWNlNGY3MGM0OGY1MzE2NDdlNTdkNzhhYzFiYThjOTE5ZTMxYmE2M2VjNGJhOWZmIiwidGFnIjoiIn0="
}```
Had already tried the response()->json() route without success. Ok I don't think the return command is being executed at all!
Not sure about this one, are you getting errors in the logs? I think a non-resolved response (meaning no explicit return or calls to response) would result in a 200 response. So it's possible something else is not working. But for this issue since it's already different from the original one, I would recommend creating a new thread for this specifically. Someone with more knowledge about Laravel may be able to help better here.
@ruthback For your interest I figured it out. My return was inside another function so I was just returning that function not the main function, added a second return and all is good.
@aarontharker Oh, of course I did wonder about that function there but as I'm not familiar with the API I thought it might have been designed this way. Good catch!