What could be the reason behind the absence of certain headers in the response from Angular.js?

Firstly, I will provide you with images of POSTMAN tests (you can find the link to the google drive containing postman.png at the end of this question)

The issue at hand is that there is a client on angular.js and a Laravel API (without access to configuration and code)

I aim to implement JWT Auth on the client. When data is sent to the API, angular.js sends the first request - OPTIONS - (you can find the image of this request in the google drive under angular-option.png)

Following the OPTIONS request is the POST request (images for POST-1.png and POST-2.png can be found in the google drive) Although the response header shows the Authorization key with my token, when I log() the request and response on the client side, this header is not present (the image showing the response on the client side can be found in the google drive under response-client.png)

Why is the Authorization header missing in this response?

Link to Google Drive

Here is the code snippet

Thank you for your assistance

Answer №1

Did you ensure that the interceptor was properly registered in your module configuration?

If yes, could you also update your signin method to check if it is logging the response there? Update the code from

signin: function (data, success, error) {
    $http.post(urls.BASE + '/auth/signin', data).then(function success(response, status, headers){

    })
}

to

signin: function (data, success, error) {
    $http.post(urls.BASE + '/auth/signin', data).then(function success(response)){
        console.log('Status:' + response.status);
        console.log('Response headers');
        console.dir(response.headers());
    })
}

When using .then for $http.post, the response object contains the following properties according to angular docs:

data – {string|Object} – The response body transformed with the transform functions.
status – {number} – HTTP status code of the response.
headers – {function([headerName])} – Header getter function.
config – {Object} – The configuration object that was used to generate the request.
statusText – {string} – HTTP status text of the response.

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

Unraveling the mysteries of interpreting the jsben.ch benchmark results

After testing three fibonacci algorithms on jsben.ch, it's clear that the first one is the fastest and even received an award icon: https://i.sstatic.net/ilfDz.png However, I'm curious about the numbers next to the code block results. What do t ...

Attempting to insert a square-shaped div within a larger square-shaped div and enable it to be moved around by dragging

Imagine this scenario: I have a button and a large div. When the button is clicked, the code adds a new div inside the larger one. However, the new div is not draggable because I didn't implement the necessary code. I'm also trying to figure out ...

Struggling to interpret the array of objects retrieved from a call to UrlFetchApp.fetch in Google App Script

When UrlFetchApp.fetch is called, it provides an array of objects that are stored in the variable 'results': var results = [{"Category 1": "Benefits/Compensatio", "Category 2": "Compensation", "Category 3": "Recognizing You", "Processing Team": ...

Ways to stop the browser from ending the connection?

I'm working on a project using node/express/react, built with create-react-app. I'm facing an issue where the browser automatically closes post requests that take longer than 2 minutes. Specifically, in Chrome, the requests are being closed at e ...

Creating a dynamic form by extracting and populating form fields with information received from a JSON data

My goal is to dynamically generate a form based on specific criteria: The form fields should be created using values from table1 and table2 keys in the entityTable array. Sometimes these keys may contain multiple values separated by commas, which need to ...

Showing both SubTotal and Total simultaneously in a JavaScript powered interface

Recently diving into Javasript, I came across the code snippet below from a different source that I tweaked to suit my needs. My goal is to show the subtotal in the third column for each benefit while displaying the total of the entire form. However, I&apo ...

What is the best way to consistently resize elements to the same pixel value, like "10px", using jquery-ui?

Is there a method to consistently resize a div element by a specific pixel value each time, such as "10px"? I am attempting to achieve this using jquery-ui, where I can resize the element but desire to resize it consistently by a set pixel value. $(child ...

Utilizing the change() and contains() functions with an HTML <select> element in jQuery

Currently, I am working on a feature where images change based on the value selected from a dropdown menu. The code provided below is a simplified version to convey the main idea. Here's the gist of what I have (feel free to ask any questions; please ...

What is the best way to implement CSS in this JavaScript Fetch code in order to manipulate the text's position and font style

Hello, I am just starting out with JS. Is there a way for me to customize the position and font of text in this JS Fetch function using CSS? Any help will be greatly appreciated. let file = 'art.txt'; const handleFetch = () => { fe ...

Failed to convert the value "hello" to an ObjectId (string type) for the _id path in the product model

i am currently using node, express, and mongoose with a local mongodb database. all of my routes are functioning correctly except for the last one /hello, which is giving me this error: { "stringValue": "\"hello\"&qu ...

Identifying user interaction with a dynamic drop-down menu using extension javascript

I'm currently working on detecting a click event on a list element using JavaScript, with a slight complication. The list element is located within a dropdown menu from a search bar on Quora. www.quora.com - Specifically, I am interested in identifyin ...

"When a jQuery button is clicked, retrieve the div element with a specific class

I'm currently in the midst of crafting a jQuery client script and my goal is to ensure it's adaptable to any situation. One specific challenge I am facing is how to target a div with the class ".targets" when a button is clicked. The structure ...

Examining AngularJS Jasmine Promises in IsolationDive into the world

Seeking help for testing a mocked Service with chained promises. Factory for Testing app.factory('factory', [ 'service', function( service ){ var baz; return { updateMe: function( updateObj ){ // do stuff with upd ...

The Ionic application encounters an issue with the $stateParams being

Can someone assist me with resolving an issue related to ionic $stateParams? Here is the state configuration: .state('tabs.categories', { url: "/categories/:parentID", views: { 'categories-tab': { templateU ...

Karma - Monitoring Function Error Management

I have a similar service setup: app.service('usersService.v2', ['$http', '$q', '$exceptionHandler', 'User', 'userValidator.v2', 'CRUD', function($http, $q, $exceptionHandler, User, user ...

Leveraging AngularJS UI-Grid's rowTemplate feature to display the plus icon in the row header

I am currently working on a group and subgroup grid using ui-grid v3.0.0-rc.20-8199eb5 - 2015-04-13. My challenge is to display plus and minus icons in the rows that contain data, excluding the grouping header. At the moment, none of the rows have these ...

Error encountered: Unable to locate module 'win-spawn'

After installing Generator-ionic in the directory where I generated the app, I attempted to run grunt server but encountered an error message stating: "Error: Cannot find module 'win-spawn'". ...

Notification regarding navigating through gridview pages

How can I display an alert when a user attempts to page through a gridview? I have implemented a script for this purpose, but the alert appears even if any other buttons on the page are clicked. Ideally, I would like the alert to only show when paging is c ...

Exclude child rows from row count in DataTable

I have successfully implemented a feature on my datatable where child rows are toggled when a parent row is clicked. Here is the code I used: $(function() { $('tr.parent') .css("cursor","pointer") .attr("title","Click to expa ...

Creating an endless variety of modals using HTML - The ultimate guide

Currently, I am in the process of developing a Project Manager website by utilizing w3school's To-do-list tutorial. To enhance the functionality, I have included a detail button (denoted by ...) that triggers a modal displaying task information. Howev ...