-1

I have some projects built with Laravel (laravel/framework v5.3.24) and Vue ^2.0.1. I ran composer update which updated laravel/framework to v5.3.26. Strangely after this update, my Vue components, using vue-resource (^1.0.3) started to have problems- the get request's Response body property was null (valid data was being output from the url in question). I cannot work out why this is the case. The success callback was being executed.

Yes, other dependencies were updated, including spatie/laravel-fractal and the usual dev-dependencies. The spatie/laravel-fractal package seemed to be working as usual and no errors in it's data output.

Is there anything that would cause these kinds of problems with vue-resource?

Luckily, I had recently pushed my work to the GitHub repo and restored the files to their previous state, and it was working fine. IMO, this hiccup was a direct result of running composer update.

Project URL: https://github.com/AshMenhennett/Salon-Pricing

I don't have any other data to post, as the only error in the console, was a result of the null body property on the Response and its data that I was trying to access.

Saurabh
  • 71,488
  • 40
  • 181
  • 244
AshMenhennett
  • 1,095
  • 4
  • 14
  • 25
  • It will be more helpful if you can add relevant code snippet here. – Saurabh Dec 12 '16 at 09:19
  • Sure. All the code is in the github repo link included in question ^^. The offending code was in ```resources/assets/js/components/ServicesTableComponent.vue```. However, rather than a programmatic error, which is no longer there, due to the 'rollback', I was wondering if there was something that I missed, build wise after updating to v5.3.26 of ```laravel/framework```. The ```fetchServices``` method, making the get request, its ```Response``` object's ```body``` property was null, after the update. – AshMenhennett Dec 12 '16 at 09:22

1 Answers1

0

In a not too old project we got a very odd problem with Laravel and Vue Resource not parsing our return data properly. So double check your content-type. Paste the code bellow with our workaround, you can use it to debug.

if( 'Content-Type' in response.headers && response.headers['Content-Type'] == 'application/json' ){
    if( typeof response.data != 'object' ){
        response.data = JSON.parse( response.data );
    }
}
if( 'content-type' in response.headers && response.headers['content-type'] == 'application/json' ){
    if( typeof response.data != 'object' ){
        response.data = JSON.parse( response.data );
    }
}
  • Thank you very much! Will try it out soon. – AshMenhennett Dec 12 '16 at 14:47
  • I updated my Laravel application's dependencies (```composer update```) on macOS, whereas before I was using Windows 10. On macOS there doesn't seem to be any issue with the ```Reponse``` from ```vue-resource``` requests. Strange. Thank you for the input. – AshMenhennett Dec 14 '16 at 04:17
  • 1
    Update: After pulling the updated ```composer.json``` file from the repository back on to Windows 10 machine, I was able to run ```composer update``` and no unexpected behavior occurred while running the application. – AshMenhennett Dec 14 '16 at 10:19