Utilize the get method in Angular HttpClient to send a body. Postman also has the capability to send a

When sending an endpoint with GET and adding the body, it returns a value. However, when doing it with Angular using HttpClient, the body does not show up to consume the backend with Spring Boot.

Click here to see how to consume with Postman

Consuming with Postman and HttpClient

Backend - SpringBoot


header = new HttpHeaders().set('Authorization', this.auth.isToken())
    .set('Content-Type', 'application/json')
    .set('Accept-Language', 'UTF-8')
    .set('Cache-Control', 'no-cache');

const url = 'api/servicios/servicios-impuestos-clientes';

const object = JSON.stringify(body);

const options = {
    headers: this.header,
    body: JSON.stringify({ 'impuestos' [1, 2] }),
    // tslint:disable-next-line: quotemark
    // tslint:disable-next-line: object-literal-shorthand
    params: new HttpParams().append('cliente', 1 + '')
};

console.log(options);
return this.http.get<Servicios>(url, options).pipe(map(result => {
    return result;
}));

Answer №1

Typically, a GET request does not contain a body. This is why the majority of HTTP clients do not support it.

However, there are exceptions to this rule.

If you're interested in learning more about this topic, you may want to explore the following question: HTTP GET with request body

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

A versatile sorting algorithm

Currently, I am working on converting the material UI sorting feature into a generic type. This will enable me to utilize it across various tables. However, I have hit a roadblock in implementing the stableSort function, which relies on the getSorting func ...

Angular HTTP Interceptor encountering issue with TypeError: (0 , x.fromPromise) function is not recognized

I have implemented the following code snippet to attach reCAPTCHA v3 to an HTTP Request: @Injectable() export class RecaptchaInterceptor implements HttpInterceptor { constructor(private recaptchaService: ReCaptchaService) { } intercept(httpRequest: HttpRe ...

Make the move to Angular 12 today and say goodbye to the NullInjectorError: No provider for InjectionToken

The original approach was initially inspired by the concept outlined in the article found at here. It worked flawlessly until I decided to upgrade it to angular 12. Unfortunately, after the upgrade, I started encountering a frustrating NullInjector error. ...

The list of TypeScript Community Stubs is not visible in WebStorm's JavaScript Libraries

It feels like I'm overlooking something obvious, but I just can't seem to figure it out. Recently, after setting up WebStorm on my new computer, I had no trouble downloading TypeScript Community Stubs libraries such as Angular and Mongoose from ...

Utilizing TypeScript Generics to Dynamically Set Tag Names in React

I am working on a straightforward polymorphic React component that is designed to render only tag names (such as span) and not custom React components (like MyComponent). I believe this can be achieved using JSX.IntrinsicElements. Here is the code snippet ...

The specified route type does not comply with the NextJS route requirements, resulting in an authentication error

Recently, I have encountered an issue with NextJS routes while working on an ecommerce project. I am seeking guidance to resolve this issue, specifically related to my route.ts file which interacts with NextAuth for providers like Google. During developmen ...

What is the suggested method for supplying optional parameters to a callback as outlined in the Typescript documentation?

While going through the do's and don'ts section of the Typescript documentation, I came across a guideline regarding passing optional parameters to a callback function. The example provided was: /* WRONG */ interface Fetcher { getObject(done: ( ...

Why does the event fail to trigger in an Angular 5 Kendo grid when the last character is deleted from the input box?

I have implemented a multi-filter in my Kendo Grid for an Angular 5 application. However, I am facing an issue where the event is not firing when the last character is deleted from the input box. How can I resolve this issue? For example, if I type ' ...

Positioning gallery images in Angular Modal Gallery

I'm currently working on implementing an image modal, but I've run into several issues. My goal is to have the first image fill the entire large box (class drop), with the rest displayed below it, as illustrated in the image. I've experime ...

Nuxt 3 turns a blind eye to TypeScript errors upon code saving

I am facing an issue. Even with a TypeScript error in the code, the IDE shows an error, but I am still able to save it and run it in the browser. Is this acceptable? Check out the code below: <script lang="ts" setup> const a = ref<strin ...

Is there a way in SQL to choose all columns, but only for every third row in the dataset?

Is it possible to select all columns, but only choose every X row? For example, if I want to retrieve all rows, the query would look like this: @Transactional @Query(value = "SELECT * FROM data WHERE job_name = :jobName ORDER BY date_time ASC LIMIT : ...

Angular Material Table displaying real-time information

Recently, I've delved into Angular and have been experimenting with creating a dynamic table to showcase data. Currently, I have managed to get it partially working with static data. I drew inspiration from this particular example: https://stackblit ...

What steps can be taken to troubleshoot the npm start problem?

I am encountering the error shown below: https://i.stack.imgur.com/jqmcF.png This issue is present on Windows but not on Linux. Which dependency do I need to install? I can't seem to locate the Color npm dependency. ...

In Angular 15, CSS override configurations do not function as intended

Exploring the world of Angular is exciting, and I am a newcomer to it. Currently, I am tackling an innovative Angular 15 project that makes use of the Material library. My current predicament lies in the fact that none of the CSS overrides appear to be tak ...

In Angular 10, the default state of the radio button is not checked

We are attempting to set the default selection for the radio button group to the Female option. <ng-template #genderTemplate> <div> <div> <label class="ari-label" for="gender">Gender</l ...

Properly Incorporating Client Libraries (TypeScript, JQuery, etc.) in Visual Studio 2019

[Updated on 16th July 2019] I'm feeling perplexed at the moment. I am diving into a .NET Core 3.x Web Application and my aim is to incorporate: jQuery TypeScript I've managed to get TypeScript up and running, but I'm facing an issue where ...

Angular - Using the DatePipe for date formatting

Having trouble displaying a date correctly on Internet Explorer using Angular. The code works perfectly on Chrome, Firefox, and other browsers, but not on IE. Here is the code snippet : <span>{{menu.modifiedDate ? (menu.modifiedDate | date : "dd-MM- ...

I am seeking to modify the CSS of the parent component upon the loading of the child component in Angular

In my Angular blog, I have a root component with a navigation bar containing router links to create a single-page application. My goal is to darken the background around the link when the child component loads. Currently, the link highlights only when pres ...

Using Services in Angular 11: A Guide to Implementing Services in Regular Typescript Files

I'm working with a utils.ts file that contains exported functions like deepCopy and sortArray. However, I need to use a service within some of these functions. How can I go about incorporating a service, such as toastService, into my utils.ts file? // ...

What is the best way to dynamically add a new item to an object in Typescript?

var nodeRefMap = {}; function addNodeRef(key: String, item: Object){ console.log("Before:"); console.log(nodeRefMap); nodeRefMap = Object.assign({key: item}, nodeRefMap); console.log("After:"); console ...