The URL being called by $http.get is incorrect

Attempting to invoke a URL through my AngularJS service, I have encountered an issue where a particular call is not reaching the intended URL.

The following code snippet depicts the function responsible for making the call, along with a console.log statement displaying the same URL that should be accessed:

this.getCategoriesByParent = function(parent) {
    console.log('http://localhost/cloqet_server/public/categories/subcategories/' + parent);
    return $http.get('http://localhost/cloqet_server/public/categories/subcategories/' + parent);
}

Upon inspection of the console output:

What could potentially be causing this discrepancy?

Answer №1

When using HTTP, the default port is 80. This means that if you send a request to http://localhost/..., it's basically like sending it to http://localhost:80/..., but without explicitly stating the :80.

If your local server is not running on port 80, you will need to specify the correct port in your URL.

For example, if your server is running on port 9000, your URL should look something like http://localhost:9000/

Answer №2

I determined that the issue stemmed from the API.

Upon accessing the URL, the API immediately redirects to the primary base URL.

Answer №3

Which server is being utilized for your api? In the case of Apache, ensure to verify the presence of a .htaccess file that manages redirection.

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

"Enhance Your Form with JQuery Date Selector for Multiple Input

Using JQuery and ASP.Net C#3.0. Here is the script I am working with: <script> $(document).ready(function () { $("[id$=txtHiddenDate]").datepicker({ showOn: "button", buttonImage: "../../images/calendar-icon.gif", ...

What are the necessary steps for incorporating Payment/Bank transactions into an e-commerce platform?

Right now, I'm utilizing HTML, CSS, jQuery, and some JavaScript to develop a website. As I work on creating the store section, I find myself unsure of how to incorporate payment methods and all related features. Are there any free "pre-built" systems ...

Determining errors with AngularJS's $http.post response

Utilizing AngularJS $http.post to communicate with PHP in my login function. The PHP script returns a token, or if none exists, the term "ERROR". PHP Script: .... echo json_encode($token); } else { echo "ERROR"; } Controller.js: var request = ...

Issue with HTTP headers not being effective in $.AJAX request

Regardless of the method I attempt to use for setting headers in an AJAX call, and no matter which header I set, every time there is a header present, the AJAX call is aborted and does not go through. However, if I try to make the call without setting any ...

Angular - Ensuring service completion before proceeding with navigation

I'm currently facing an issue where I need to populate data in a service before navigating, but the navigation is happening before the data is ready. Here's the code in my service: addToken(token) { this.cookieService.set( 'token', ...

Exploring the properties of a file directory

As I try to access the d attribute of a path that was generated using Javascript, the output of printing the path element appears as follows: path class=​"coastline" d="M641.2565741281438,207.45837080935186L640.7046722156485,207.0278378856494L640.698 ...

Explore ways to showcase a list of calendars through the Google API with the use of Java Script

I'm experiencing difficulties with displaying a list of accessible calendars from Google Calendar using the Google API. I am utilizing JavaScript and AJAX to achieve this. What specific methods do I need to implement? I have only come across event-re ...

Choose a selection in ExtJS by finding matching attributes

Is there a convenient method to choose an item in an Ext.tree.Panel by matching it with an item based on the same attribute in an Ext.grid.Panel? For example, using something like: tree_dir.getSelectionModel().select(grid_file.getSelectionModel().getSelect ...

In JavaScript, the price can be calculated and displayed instantly when a number is entered into a form using the input type 'number'

Is there a way for me to automatically calculate the price and display it as soon as I enter a number into my form? Currently, the price is only displayed after I press submit. <script type="text/javascript"> function calculatePrice() { ...

Is there a built-in method called router.reload in vue-router?

Upon reviewing this pull request: The addition of a router.reload() method is proposed. This would enable reloading with the current path and triggering the data hook again. However, when attempting to execute the command below from a Vue component: th ...

Suddenly, the Bootstrap CSS appears to have ceased functioning

Here are some of the questions I've already checked out: Bootstrap JavaScript not functioning Twitter Bootstrap dropdown suddenly not operational Comprehensive list of possible issues causing a CSS file to fail All of a sudden, my Bootstrap sty ...

Issue: Module 'xml2json' not found

Encountered an error while running my project package. When I tried to install the necessary packages using npm install xml2json I still encountered another error below. Can anyone provide suggestions or ideas on how to resolve this issue? D:\xa ...

Clouds marred by a unpleasant visual presentation

I've been following the instructions on this specific tutorial, but I'm attempting to scale it up significantly (increasing the radius to 100000 units). It seems like the size may be affecting the outcome, as the clouds in my earth render are ap ...

Is it possible to pass a parameter to an NGXS action that is not the Payload?

I am working on implementing an Ngxs action that includes a parameter in addition to the payload. This parameter is used to determine whether or not a notification should be sent. @Action(UpdateUser) async UpdateUser( ctx: StateContext<ProfileStat ...

What is the best approach to retain a user's selection for dark mode?

I have created a small website to showcase my work, but I'm struggling to figure out how to make the website remember a user's choice of dark mode. After searching on Stack Overflow, I came across suggestions like using cookies or localStorage. ...

Utilize modules within the AppModule to promote modularization and maintain separation of concerns in Angular 2

When using templates like those from the ASP.NET Core JavaScript services, typically a single module named AppModule is included. However, in my application, which is divided into two logical areas (AreaA and AreaB), I thought it would be better to use two ...

What is the best way to determine if certain rows of data have been successfully loaded when working with Ext.data.operation and an ajaxProxy?

Here is the provided code snippet: Ext.define('Book', { extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'int'}, {name: 'title', type: 'string'}, {name: &apo ...

transmit information using GET parameters in a non-array format

I wish to directly send the data via parameters instead of using an array This is how the console is displaying the data: enter image description here I want it to be sent in this format directly: ID: 3 Description: Executing Code: refresh () { this.$ ...

The WkWebView Message handler fails to return the value of the textbox initially, but successfully does so after pressing the button a second time

Having an HTML form embedded in a WKWebView in my Swift app poses a problem when trying to extract the textbox content using a message handler. The issue arises when pressing the Register button, which triggers a JavaScript function to retrieve the values ...

Is there a way to retrieve a large number of users through an API using async await?

I am trying to retrieve all users from an API and I want to identify which user receives the highest payment. For instance let users=['tom','jenny','smith','Joe'] async function getUsers() { let response = awa ...