"Invalid response for blob" Error When Making XHR Request

Whilst making a request to one of my API endpoints for an iOS application, I came across a very unhelpful error: "Invalid response for blob". I couldn't really understand why React Native was complaining about this single API endpoint, since all my other endpoints did not encounter this error.

React Native: Invalid Response For Blob

The API endpoint in question is a pretty simple email address validator. If the users email address is unique and passes all verification checks, the endpoint will either return a 200 (OK) or 400 (Bad Request) along with a response containing the error. For those who understand ASP.NET Web API development, my endpoint is as follows:

/// <summary>
/// Check if a user's email address is not already in user along with other string validation checks.
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
[Route("EmailAddressValidator")]
public HttpResponseMessage EmailAddressValidator(string email)
{
    if (UserLogic.IsEmailValid(email, out string error)) // UserLogic.IsEmailValid() method carries out email checks...
        return Request.CreateResponse(HttpStatusCode.OK);

    return Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorModel { Error = error });
}

So pretty simple stuff!

Weirdly enough the "Invalid response for blob" issue did not occur within my endpoint when the users email address did not pass the required checks, thus returning a 400 error and a response detailing the error. It was only when a 200 response was returned without a value.

There seems to be a bug in the React Native environment when it comes to dealing with empty API responses. The only way I could get around this, is to always ensure all my API endpoints returned some form of response. Very strange! I suggest all you fellow React Native developers do the same until a fix is put in place.

The issue has already been logged so I will be keeping an eye on a release for a fix.

Update (16/07/2018)

I wasn't too sure to whether anything had been done in regards to the fix since writing this post as there was no update to the Github issue that was first logged on the 5th March. So I decided to share this very post to a React Native group on Reddit to get some form of answer. Within a short period of time, I was told this issue has been fixed in React Native version 0.56.

iPhone SDK Error: Base SDK Missing

I am currently in the process of learning how to build applications for the iPhone. I have recently upgraded from the iPhone SDK 3.0 simulator to the iPhone SDK 4.0 simulator. But this caused some issues when trying to run some of my previous applications I developed prior to when I had the iPhone 3.0 simulator installed.

Normally, the dropdown box within the XCode window allows you to select different simulators. For example: iPad Simulator 3.2 or iPhone Simulator 4.0. As you can see from my screenshot (below), none of these options were available.

Base SDK Missing

Apparently, the iPhone 4.0 SDK can still have the ability to run iPhone 3.0 applications and this is something we should be doing from now on. This requires a couple of changes to carry out in your older 3.0 projects.

Firstly, you will need to go to Project > Edit Project Settings. When the window appears, click on the Build tab and change the “Base SDK” value to “iPhone Simulator 4.0”.

Edit Project Settings

Secondly, go to Project > Edit Active Target. When the window appears, you will have to carry out the same procedure as you carried out in the “Edit Project Settings” whereby you click on the Build tab and change the “Base SDK” value to “iPhone Simulator 4.0”.

Edit Project Target
If you have carried out the changes correctly, you should be able to Build and Run your project successfully. I admit this is not exactly ideal to do this if you have many iPhone 3.0 application projects. But I suppose this fix is better than nothing and plus its quite a quick change.