question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Won't decode JSON

See original GitHub issue

On my production server, vue-resource won’t unwrap a json response, despite having the correct Content-Type headers.

The issue only appears in chrome and is reproducible:

Production Server

On my Testserver, the very same line produces the following output (compare data attribute):

Test Server

I tried removing the custom X- headers and other things, but I just can’t get it to run properly…

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

22reactions
Jigsaw5279commented, Jul 3, 2016

Yup. Solved the Issue by using a custom interceptor:

Vue.http.interceptors.unshift(function(request, next) {
    next(function(response) {
        if(typeof response.headers['content-type'] != 'undefined') {
            response.headers['Content-Type'] = response.headers['content-type'];
        }
    });
});
0reactions
jeimancommented, Apr 13, 2018

Hey guys, curious to know and it’s my first time playing around with Vue, where do I go about applying that solution?

Do I patch it in my main.js - where all my vue components are being instantiated from? or do I use it when I make a HTTP request ?

I am facing the same issue with my v-for inconsistency with my local and production server.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Decode JSON API response - Stack Overflow
Here's what I do and it might be completely wrong. I take a PHP array and encode it. Then echo or print_r that...
Read more >
Getting error in json decode | Apple Developer Forums
Actually i am trying to decode one json object but getting error " Type Missmatch" i do not know how to create a...
Read more >
Cannot decode JSON - WordPress.org
Cannot decode JSON · 1. Edit your wp-config.php script. · 2. Search for: define('WP_DEBUG', false); · 3. Replace with: define('WP_DEBUG', true); · 4....
Read more >
How do I decode JSON in PHP? - ReqBin
To decode a JSON string or file in PHP, you can use the json_decode($json, $assoc, $depth, $options) function. The first parameter specifies the...
Read more >
SOLVED: Decode JSON error – SwiftUI - Hacking with Swift
I tried using the debugging statements from this HWS Forum post to see what is going on but the way that the JSON...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found