How to submit an ajax request using cljs-ajax and specifying body keys without using colons

Currently, I am utilizing cljs-ajax to make a POST request like so:

(POST "http://example.com/some/endpoint"
      {:body {:username "me"
              :password "pass"}
      :handler some-handler
      :error-handler some-error-handler})

The issue is that the request payload includes colons before keywords. For instance, instead of sending username, it sends :username. Even after adding :format :json, the problem persists.

What mistake have I made in my implementation?

Answer №1

Although I am new to using cljs-ajax, after reviewing the documentation, it seems that using :params instead of :body is recommended. This way, cljs-ajax will interpret it as a POST request and transmit the data in the body. For a GET request, the information would be included in the query string.

:params - the parameters that will be sent with the request, format dependent: :transit and :edn can send anything, :json, :text and :raw need to be given a map. GET will add params onto the query string, POST will put the params in the body

If it doesn't work initially, remember to include those JSON format flags.

I'm curious to hear about your progress with this. Keep me updated!

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

`Python automation for seamless HTTP browsing and HTML document generation`

My weekly routine at work involves printing out Account analysis and Account Positions for more than 50 accounts every Monday. I have to navigate through the page, select "account analysis", input the account name, format the page for printing, print the o ...

Leverage the power of Drupal 7's AJAX capabilities through program

Posted by X on this Drupal blog post Exploring the wonders of the Drupal 7 AJAX system, it seamlessly handles forms and links with finesse. However, one challenge I've encountered is calling it from JavaScript in a streamlined manner. Imagine creati ...

Unusual occurrences when making several ajax requests to a single URL

I've encountered a peculiar scenario while working on a CherryPy server, and I'm seeking assistance in understanding the intricacies behind it. Here's the content of server.py: import cherrypy import os import threading class Root(object): ...

Whenever attempting to choose a rating, the MUI dialog continuously refreshes and resets the selected rating

I'm facing an issue with my MUI dialog where it keeps refreshing and resetting the selected rating every time I try to rate a movie. Any assistance on this matter would be highly appreciated. The RateWatchMovieDialog component is designed to display ...

Non-sticky hamburger menu is not fixed in place

Having trouble with the hamburger menu staying sticky? The hamburger icon remains in the corner as you scroll down, but the menu stays fixed at the top of the page, making it hard to access. You tried tweaking the code you found on Codepen, but couldn&apos ...

Combining the results of two separate API requests using jQuery/ajax

Hello there, Internet World! This is my first post here, so please be kind. I have gained a lot of valuable knowledge from this site so far, and now I am in need of some help. I have experimented with various code variations such as $when & $then, fu ...

Executing SQL Commands

Trying to figure out how to dynamically insert a row into an HTML table and then update the corresponding database entry. There's a SQL prepare and execute statement in a separate PHP file, but I need to find a way to include variables inside the exec ...

What could be causing the jQuery effect to not function properly?

After completing a course on Codecademy, I successfully ran the code. However, I prefer to copy and paste the code into my own jquery folder for future reference and practice. The objective of this project was to make the element 'krypton' bounc ...

When running npm run build, an error with the error code ELIFECYCLE is

For some time now, I have been following the "ES6 for everyone" series by Wes Bos, but I hit a roadblock while trying to tackle a webpack episode. Every time I attempt to execute the "npm run build" command in my CMD prompt, I encounter this error: npm ...

How to efficiently manage multiple objects as a unified entity in Three.js

Hello, I am new to the world of three.js and I am facing a challenge. I want to combine multiple objects into one single entity, essentially creating a bas-relief effect. Specifically, I need to render the following elements: A box geometry serving as th ...

Monitoring user clicks using JavaScript code implemented

Currently, I am utilizing a JavaScript file to load on certain pages in order to track various events. Within this JavaScript file, there is a collection of selectors that have listeners attached to them. When these selectors are clicked, the tracking AP ...

What is the best way to update the content of a div using a variable within a function in AngularJS?

I have a dilemma with my HTML pages. The index.html page displays product information from a JSON file, and I want the details of a specific product to show up on detail.html when users click on it. Though an alert can display the details, the innerHTML of ...

Tips on using an array filter in AngularJS ng-repeat

I have successfully used ng-repeat to display my data. Within the ng-repeat result set, one of the data fields is an array of items. Example: {x:1, y:[2,3,4]} I want to filter the data based on the values inside the array. Filtering by non-array data is ...

Initializing start scripts in the package.json file

When launching my react app locally, I need to execute three commands: cd react-web npm run postinstall export REACT_APP_CUSTOMER_ENVIRONMENT=xxx npm start After running these commands, the application server starts on localhost:3000. For the start script ...

The boolean value remains constant when using useState

An Alert module pops up when incorrect credentials are entered by the user. It includes a close button designed to hide the alert. The alert function operates correctly on the first instance, displaying a boolean value of true upon activation and switching ...

Error: Attempting to update the value of 'ordersToDisplay' before it has been initialized in a re-render of React. This results in an Uncaught ReferenceError

Trying to dynamically update the document title to include the order number by clicking a button to display different numbers of orders from an array on the screen. The process involves importing a JSON file, filtering it based on user input, calculating ...

Updating online status with Firebase and AngularJS when switching windows

Hi there, I'm currently looking to implement a stateOnline attribute for each user in my web app (using Angular 5 + Firebase). I came across some solutions for Android and attempted to adapt them for my needs: signInUser(email: string, password: st ...

Receiving JSON in a C# web service: A step-by-step guide

I created a JSON string using jQuery and now I want to send it to a C# web API controller. Here is an example of the JSON object: {"Name":"","Type":"4","Meals":["2","3"],"Excludes":["Beef","Chicken"]} I attempted to send it with a URL structure like thi ...

Creating a PDF from a GridView in C# using iTextSharp 5.5.10 and adding a title to the PDF document (for beginners)

It seems like every piece of code I find online is either incomplete or not functioning properly. I am trying to use a dropdownlist within an Ajax update panel and have it update a gridview when the index changes. The gridview is functioning correctly, bu ...

JavaScript array displaying excess whitespace in its presentation

https://i.sstatic.net/5AdA7.png One issue I am facing is that when I use console.log(a), it adds extra spaces which then flow through to the backend. This leads to each element breaking after the first one. How can I resolve this problem and why does it o ...