No content returned with 200 status code in response to ajax post request specifically on a mobile browser

Just want to say thank you in advance. I tried searching online for a solution to this issue, but couldn't find anything that worked. Currently, I am working on a web application using vue.js for the front end and AWS Lambda functions with API Gateway as the REST service. In my web app, there is a login component that makes an ajax call to an AWS endpoint. For this ajax call, I am using axios.post.

Here is a snippet of the code:

loginUser(username, password) {
        const vm = this;

        var apiUrl = `${this.host}/user/login`;
        const requestBody = {
            username: username,
            password: password,
        };
        axios
            .post(apiUrl, requestBody, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json'} })
            .then((response) => {
                window.console.log('Login Response')
                window.console.log(JSON.stringify(response))
                store.dispatch('login', { user: response.data, error: '' });
                vm.resultSubject.next(response.data);
            })
            .catch((error) => {
                vm.resultSubject.error('Failed Login');
                window.console.log(error);
            });
        return this.resultSubject;
    }

Everything seems to be working fine when I log in using a laptop browser, but when I try the same on my mobile browser, I get an empty response. The status code is 200, but no response data is returned. Interestingly, a GET call works without any issues. Here are some screenshots demonstrating the problem:

network tab iphone safari - empty response

console tab iphone safari - response logged with actual js file

network tab laptop safari - with response

console tab laptop safari - response logged with data

network tab iphone safari - with response on different GET call

Answer №1

The root cause of the issue lies within the server-side code.

The unusual behavior experienced on mobile devices is a result of the username being automatically camel-cased by the mobile browser. While typing in the username "abc_xyz" on a desktop browser, it remains as is, however, on mobile it becomes "Abc_xyz", causing the server to fail in locating the user in the database. The server code lacks proper handling for case insensitivity of usernames and does not effectively manage error scenarios. This incident serves as a valuable lesson to thoroughly examine the details of the request body.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide on resetting v-modelReady to learn how to reset

I am struggling with a toggle and reset button implementation: <template> <label :for='id + "_button"' :class='{"active": isActive}' class='toggle__button'> <input type='checkbox&ap ...

Retrieve calling image from array on rollover

Currently working on a website where I want to incorporate multiple rollovers using the same base image (distributed black pixels all over the page to create a popup effect). I decided that the best way to approach this is to use an array with all the ro ...

Adapting the current codebase to be compatible with Typescript

Currently, my codebase is built with redux, redux-saga, and react using plain Javascript. We are now considering incorporating Typescript into the project. Some questions arise: Can plain Javascript files coexist with tsx code? I believe it's possibl ...

Utilize the identical template in separate locations for rendering within a Vue component

Here is the component in discussion: <template> <div> <!-- If usecard is true, a wrapper should be rendered --> <v-card flat v-if="usecard"> <v-container> <!-- The errors template ne ...

Node.js can provide a reusable email framework that can be used across

When it comes to sending emails based on specific business functions in nodejs, I have been following a particular approach. However, I am exploring the possibility of improving this method by composing email content more efficiently. Instead of hardcoding ...

Is there a way to retrieve two distinct values from an object?

Is there a way to retrieve two target values from an option using useState in react/nextjs? Here is a sample of my api: const movies = [ { id: 1, name: "Fight Club" }, { id: 2, name: "Titanic" }, { ...

How come my ajax function is not processing when the form is submitted?

Having an issue with validating a form where I need to check if a username is available before submission. Although all functions, including the PHP script for checking the username, are working properly, I'm unable to prevent the form from submitting ...

Learn the process of eliminating special characters from input or textarea fields with AngularJs!

My attempts to integrate an AngularJS directive to remove special characters from input and textarea fields have been unsuccessful. Despite no errors being reported in the console, I am facing issues with the character count tooltip not displaying numbers ...

What is the best way to apply multiple conditions when filtering a nested array of objects?

In the array of objects provided below, I want to filter them based on the criteriaType, id, and source. If none of the input sources match, the parent object should be filtered out. It's important to note that all filter criteria are optional. [{ ...

Inability to input text into a textbox with AngularJS

I am currently working on developing an AngularJS app. I have encountered a problem where I am unable to input text into a textbox. The issue lies with my zoomService which handles zoom increments and decrements. While the user can zoom using a slider and ...

Accessing data from an array using onClick in a React component

I have an array.map of buttons that cycles through API data. When a button is clicked, I want to take that specific button's data and store it in local storage. I've been searching on Google but can't figure out how to do this. Any ideas? {t ...

React 16 is able to efficiently render an array of numbers into table data using the map function

In my quest to display the most frequently used words, I have successfully fetched data from an API. I have set up the state for words and mapped the array in render(). However, instead of displaying the words along with their counts, I only see numbers ...

How can I utilize the replace function in Angular to swap out a character?

I am attempting to change the characters { and } in an HTML string to {{ and }}. However, when using the replace function, I encounter the following error: $scope.selectedtemplate.template.replace is not a function Below is my code: $scope.selectedte ...

Prevent typing in text box when drawer is activated by pressing a button

update 1 : After removing unnecessary files, I need assistance with https://codesandbox.io/s/0pk0z5prqn I am attempting to disable a textbox. When clicking the advanced sports search button, a drawer opens where I want to display a textbox. The toggleDra ...

Utilize JavaScript to Trigger AJAX HoverMenuExtender in .NET

Within my C# web application, I am attempting to trigger an Ajax HoverMenuExtender using JavaScript, rather than relying on hovering over a designated control. When I set the TargetControlID of the HoverMenuExtender to a control on the page and hover ove ...

Retrieve information from an array of objects by utilizing a separate array

There are two separate arrays provided below: ages = [20,40,60]; doctors = [{ "name": "Moruu", "age": 18, "sex": "Male", "region": "Africa" }, { "name": "Khol ...

The clearTimeout function in React stateless components does not appear to be functioning properly

I am facing an issue with a component that I developed. In this component, one value (inclVal) needs to be larger than another value (exclVal) if both are entered. To ensure that the function handling this comparison doesn't update immediately when pr ...

Setting the default dropdown option in Angular

For my latest question, I decided to utilize ng-init. However, upon loading the page, I noticed that there is a blank default option. When I click and select another option, the blank option disappears. How can I remove this initial blank option? Here is ...

Unlocking the power of bitwise operations in VueJS with Javascript

Forgive me if this sounds like a silly question. I'm currently using vue-moment within my Vue.js application and I have the following code snippet: <!-- date = '2020-03-23 01:01:01' --> <span>{{ date | moment('from', & ...

Transforming Toggle down div into a sliding animation from right to left using javascript

Hey there, I have two divs - one named basic and the other advanced. There's a button to show the advanced div. Currently, when I click on the button, it toggles down. However, I would like it to slide from right to left instead. Here's the HTML ...