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.

The server returned an empty string for GET

See original GitHub issue

Our server is not something we can modify, and seems to return an empty string for a get with a certain EndPoint. Whilst this only shows in the console as an error, an exception is thrown which causes execution to skip through our catch block.

Everything works ok, the backend performs the work and returns as it always does, however I need a better way to handle and parse this error. Any suggestions?

  this.get('ajax').request('/users/restorepassword/' + this.get('username'), {})
    .then(function() {
      _this.set('infoMessage', 'Please check your email!');
      _this.set('errorMessage', '');
    })
    .catch(function(error) {
      // Execution reaches here, everything is ok, the server returns 200 (with an empty string)
      _this.set('infoMessage', '');
      _this.set('errorMessage', error);
    });

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
thisFunctioncommented, Sep 25, 2017

@ezekg, I had the same problem and adding dataType: 'text' to post method fixed the error

1reaction
ezekgcommented, Apr 18, 2017

I’m seeing this issue as well. API is responding with 202 no content but it’s still trying to parse the response as JSON. Having to do this as a workaround:

this.get('ajax')
  .post(`https://api.example.com/foo/bar`, {
    contentType: 'application/json',
    data: JSON.stringify({ data })
  })
  .catch((e) => {
    if (e.message === "Unexpected end of JSON input") {
      return RSVP.resolve()
    } else {
      return RSVP.reject(e)
    }
  })
  .then(() => {
    // …
  })
  .catch((e) => {
    // …
  })
Read more comments on GitHub >

github_iconTop Results From Across the Web

Express server returns empty string as a response for proxied ...
The server fetches and logs the expected data. But the frontend logs empty string despite the backend returning the exact data logged.
Read more >
GETPATHINFO() RETURNS EMPTY STRING INSTEAD ... - IBM
User has servlet that uses method getPathInfo(). According to the Servlet Spec 2.3, it should either return a string with a leading slash...
Read more >
empty - Manual - PHP
Returns true if var does not exist or has a value that is empty or equal to zero, ... $b==(int)$c -> true, because...
Read more >
Request.ServerVariables() returns empty - ASP.NET
If you try to access the Request.ServerVariables("LOGON_USER") variable in ASP.NET, an empty string is returned. If you are using Microsoft ...
Read more >
Why is my client server program only returning empty lines ...
Note, you do not need to send any data to the server, just receive from it. ... ok wow. that is exactly what...
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