Creating hashbang #! URL patterns for handling REST requests in client-side applications

I'm currently working on a single page application with my own custom router implementation.

window.onhashchange = function(event) {...

Within the URL structure, I am using hash bangs similar to the following examples:

#!/products
#!/products/1

#!/brands
#!/brands/1

However, it appears that these hash bangs primarily focus on GET requests. I am looking for a REST-based convention that utilizes clean URLs based on industry standards, similar to those used in Angular and React, to indicate when a request should be a POST or DELETE.

This way, the router can properly dispatch the respective calls accordingly.

Answer №1

Hashbang URLs are not used to make REST-based remote calls, but rather to indicate the current state of a single-page application. The state refers to the type of content visible for a specific hash bang URL.

For example, when using #!/products, display product-related forms, controls, and associated content; and similarly for #!/brands.

It is up to the developer to interpret user actions on the displayed content and translate them into REST-specific calls.

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

What could be the reason for express-validator's inability to identify missing fields during the validation of XML input

My server, based on Express, is set up to parse XML instead of JSON using body-parser-xml. To validate the input body, I am using express-validator as shown in the following simplified example: router.post("/", body('session.credential[0].$.usern ...

What is the proper method for passing arguments to a function?

I'm facing an issue with a function in nodejs that uses res.execSync with multiple parameters. More information can be found here: https://github.com/xdenser/node-firebird-libfbclient The function format is as follows: function execSync(param1, ...

Is it possible to modify an HTML element when hovering over it in an ASP.Net page?

Is there a way to use jQuery to show the child span text - SomeClassChild3 string when hovering over the parent div - SomeClassParent in an aspx page? Here is the JavaScript section of the code: function ShowDiv(Somedata){ for(var v in Somedata){ va ...

Is it Unwise to Depend on Props within the useReducer Hook?

Within my App() component, I utilize props named data. This particular component relies on a useReducer hook to manage its state. The reducer function is responsible for determining when to display or hide specific data based on the state. Additionally, it ...

I am having trouble getting the Audio Code (a very basic code) to function properly

<audio id="myAudio" src="Avengers.mp3" type="audio/mpeg"></audio> <script> window.onload = function(){ document.getElementById('myAudio').play() } </script> Recently experimenting with some code in NotePad, a friend had ...

"Implementing legends in charts with c3.js and JSON data: A step-by-step guide

Utilizing the C3 chart library to showcase data in my project, I aim to display legends (labels) instead of numbers on the AxisX: Data JSON format: [ {"Label":"DQUA","Aut":3.75,"NoAut":3.75,"CM":32}, {"Label":"DPRO","Aut":43.9,"NoAut":0,"CM":144} ...

Combining values from multiple arrays into a single array using JavaScript/Reactjs

I am working with an array that contains arrays as its values. My goal is to generate an output that includes all the array values. Please note: The input array and its elements (arrays) do not have a fixed length. Input: array = [ [a,b], [c,d,e], ...

Managing individual HTTP responses within Angular 6

I currently have 15 HTTP requests being sent to the API individually. Instead of waiting for all requests to finish processing (especially one that can take a few minutes), I want to handle responses as they come in. On the service side: findOneByOne ...

Trouble encountered while attempting to utilize @click="checkedInput" for displaying checkbox label in Vue.js?

const app = new Vue({ el: '#app', data: { checkedNames: [], checkedName: true, close: false }, methods: { uncheck(checkedName) { this.checkedNames = this.checkedNames.filter(name => name !== checkedName); }, ...

Global jQuery variables are unexpectedly coming back as "undefined" despite being declared globally

I need to save a value from a JSON object in a global variable for future use in my code. Despite trying to declare the country variable as global, it seems like it doesn't actually work. $.getJSON(reverseGeoRequestURL, function(reverseGeoResult){ ...

Is sending cookies the sole method to convey a directive from a server to a client for the execution of JavaScript code?

Simply put: How can a server send a message to a client to run JavaScript code on a page? It's not an Ajax request, but a basic GET browser-server request. Imagine this code in my app's front-end JavaScript file: if( condition_1 ) { FB.get ...

The HTML code for the base64 image conversion failed to load

I am facing an issue with handling HTML strings containing base64 image tags generated by Summernote. I have a process in place where I load the image elements, convert them to image blobs, upload them to get the image-url, and then update the src attribut ...

Node.js is throwing a JSON parsing error due to an unexpected end of input

Currently, I am attempting to analyze the JSON data that is returned using the following PHP code snippet; $UserData = $con->query("SELECT * FROM Discord WHERE RobloxID=".$UserId) or trigger_error($mysqli->error); $result = $UserData->fetch_a ...

Scanner (IE5) impact on page load speeds

I have developed an MVC project which is designed as a single-page application (SPA) utilizing knockoutjs and sammy frameworks. The following script is placed in the head section of the page: <script> var startTime = (new Date()).getTime(); </ ...

The functionality of OnPress for React Native Google Places Autocomplete is hindered by its surrounding parent components

I'm currently implementing the react-native-google-places-autocomplete library in my React Native application. However, I've encountered an issue when trying to select an address from the suggested list provided by Google. Whenever I click on a s ...

Comparing the $viewValue in AngularJS with the ng-model attribute or an object parameter

I am working on a dynamic form that uses ng-min/ng-max for validation. The ng-max and ng-min are connected to object parameters modelParam.maxvalue and modelParam.minvalue. I need to show an alert or error message if the value entered in the form field goe ...

Trouble arises when trying to invoke a prototype function using setInterval

Having created a prototype class for Bot, I encountered an issue. Upon calling the init() function after its creation, it correctly alerts "a 5000". However, when the prototype function calls getUpdates(), it fails to reach the value of "this" and instead ...

The if-else statement is providing a misleading outcome

While working on my map using leaflet, I decided to implement a dynamic color concept based on input data. However, despite comparing 3 sets of data to ensure accuracy, some parts of the color scheme are displaying incorrect results. Below is the snippet o ...

How to make an HTTPS REST API request in Node.js with JSON body payload

Currently, I am attempting to make a secure HTTPS REST request in Node.js by utilizing the following code: var querystring = require('querystring'); var https = require('https'); var postData = { 'Value1' : 'abc1&ap ...

Contrasting createMuiTheme and getMuiTheme

When would you choose to use one over the other? What are the key differences in how they operate? ...