Using iOS to send a request - Receiving a response with a 304 HTTP status code from

I am currently in the process of developing an application specifically designed for iPad users. To create this app, I am utilizing Express and a restful approach as the backend framework. The code snippet below demonstrates how Express should respond on the route GET /baumkontrollen:

exports.getAll = function(req, res) {
    if(req.cookies.email) {
        pq.getBaumkontrollen(function(rows) {
            res.send(rows);
        });
    }
    else {
        res.send(400, 'Sie sind nicht eingelogt.');
    }
};

Despite following the specified code structure, my console displays the message: GET /baumkontrollen 304 23ms

When making requests using my iPad, the process involves the following steps:

NSMutableString *serverString = [[NSMutableString alloc] initWithString:BKServerURL];
    [serverString appendString:@"baumkontrollen"];

    serverNSURL = [[NSURL alloc] initWithString:serverString];
    req = [[NSMutableURLRequest alloc] initWithURL:serverNSURL];
    [req setHTTPMethod:@"GET"];
    [req addValue:cookies forHTTPHeaderField:@"Cookie"];

    serverConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES];

The variable cookies is declared as type NSArray. What could be causing the receipt of a 304 HTTP Status Code?

To further elaborate, please refer to the request logs from the iPad by clicking here.

A comparison can be made with the successful response on my browser by accessing this link, where a status code of 200 is returned.

Answer №1

To resolve the issue, I included the following code in the request:

[request setValue:@"no-store, no-cache, must-revalidate" forHTTPHeaderField:@"Cache-Control"];

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

How to access nested JSON elements in Javascript without relying on the eval function

Below is a JSON that I am trying to access. { "orders": { "errorData": { "errors": { "error": [ { "code": "ERROR_01", "description": "API service is down" } ] } }, "status": " ...

Utilize React JS to incorporate multiple instances of the Bootstrap carousel within a webpage using Reactstrap

I am having difficulty using the bootstrap carousel multiple times on a single page. I have attempted to copy it as a new item numerous times, but I keep encountering errors. <CarouselItem onExiting={() => setAnimating(true)} onExited={() => ...

The POST method in Node JS request-promises does not properly handle string inputs

When I am trying to establish a connection between my node.js module and another server, I utilize the 'request-promise' library. My implementation for posting data looks like this: rp.({ method: 'POST', headers:{ 'Conte ...

Is it necessary to implement both JWT and Passport in a Node application?

I've been delving into the intricacies of user login authentication process for my MERN app that I'm currently developing. Most tutorials I come across advocate for using both passport in conjunction with jwt, and I find myself struggling to gras ...

Navigating nested JSON structures in React JS - a guide to iteration

I am struggling with efficiently navigating through a JSON file that is obtained by making an API call. My intention is to utilize this JSON data for mapping purposes and generate components based on it. Issue: How can I effectively traverse nested JSON d ...

Leveraging the api.call function to parse JSON data in a nodejs

I'm currently working on extracting data from a JSON response obtained through an API. Although I am able to stringify the response, I'm facing difficulties in parsing the JSON data and specifically retrieving the value of "display_name" into a v ...

Ensuring secure passwords through express-validation for password equality validation

Looking for guidance on validating form inputs with express-validation. Overall, everything is functioning properly except for checking if the password fields match. // form validation req.checkBody('name', 'Name is required').notEmpty ...

Issue with loading the schema in the angular.json configuration file

Encountering an issue within the angular.json file that needs attention. { "resource": "/e:/P dev/project/Resume_generator/front/angular.json", "owner": "_generated_diagnostic_collection_name_#1", "c ...

Unable to submit /api/sentiment

I'm currently troubleshooting the /api/sentiment endpoint in postman and encountering a "cannot POST" error. I have confirmed that the routes are correct and the server is actively listening on port 8080. Interestingly, all other endpoints function wi ...

Ensuring Code Execution Order in NODE.JS

I've encountered an issue with my code that involves parsing a pcap file, storing the data in an array data = [], and then writing it to a JSON file: var fs = require("fs"); var pcapp = require('pcap-parser'); var hex = ""; var data = []; v ...

What steps are involved in bundling a Node project into a single file?

Recently, I've been using npm to create projects. When it comes to AMD, I find the native node require to be very convenient and effective for my needs. Currently, I rely on grunt-watchify to run my projects by specifying an entry file and an output f ...

What is the best way to format WIQL JSON?

When using Postman, I have no trouble submitting a query to our Azure DevOps 2019 Server: POST https://<AZDOSERVER>/<COLLECTION>/<PROJECT>/<TEAM>/_apis/wit/wiql?api-version=5.0 {"query": "Select [System.Id] From WorkItems WHERE [Sy ...

Node JS is optimized for handling multiple clients concurrently who are posting data

Node.js requires careful handling of POST requests, as the post data may arrive in chunks that need to be concatenated together. Here's an example of how this can be done: function handleRequest(request, response) { if (request.method == 'PO ...

Looking for guidance on integrating cookies with express session? Keep in mind that connect.sid is expected to be phased out

Within my app.js file, I have the following code snippet: app.use(session({secret: 'mySecret', resave: false, saveUninitialized: false})); While this setup functions correctly, it triggers a warning message: The cookie “connect.sid” will ...

Enhance the text with the inclusion of variable data

The object that I am receiving looks like this: { Id:3233, Topics:"topic", TopicId:101, Alreadyactiontaken:null, … } However, for the API, I need the JSON format to be as follows: { "Data":[ { "Id":477, ...

Converting a promise of type <any> to a promise of type <entity>: A beginner's guide

As a newcomer to TypeScript and NestJS, I am wondering how to convert Promise<any[]> to Promise<MyEntity[]> in order to successfully execute the following code: const usersfromTransaction = this.repoTransaction .createQueryBuilder() ...

Having trouble with Grunt and Autoprefixer integration not functioning properly

Joining a non-profit open source project, I wanted to contribute by helping out, but I'm struggling with Grunt configuration. Despite my research, I can't seem to figure out why it's not working. I am trying to integrate a plugin that allow ...

SASS compilation in Materialize

I am exploring Materialize for the first time and I am new to SASS. To get started, I installed the materialize-sass package by running npm install materialize-sass --save. My next step is to create a color set and compile the CSS file. Could someone guid ...

I can't seem to get the post method to work properly for some unknown reason

Hello there, I am encountering an issue while trying to submit a form on my website using the post method. For some reason, it keeps returning a null value. However, when I send data not through the form but instead by reading axios, it works perfectly fin ...

Modifications made to the CSS file do not have any impact on React-Slick

Recently, I've been experimenting with altering the appearance of a React-Slick carousel within my GatsbyJS project. Within my Slider component, I followed the official documentation by importing the library as shown below: import Slider from "re ...