Questions tagged http

Explore the latest questions and answers asked by our top developers.

Is using async/await in promise request more efficient? [closed]

What is the best way to make requests? I have an http request method in project.service.ts. I can make the request with the following structure: getProjectById(projectId: number) { return this.http.get<Project>(`${this.url}/search/projects/${projectId}`).toPromise(); } And call it with the following structure in project.component.ts: async getProject(projectId: number) { this.isLoading = true; try { this.project = await this.api.projects.getProjectById(projectId); } finally […]

Error Angular Post to an API (TypeError: Cannot read properties of undefined (reading ‘id’))

I can’t resolve this error, ty for the time that you will take for my problem This message appear in my terminal when i try to post the form : TypeError: Cannot read properties of undefined (reading ‘id’) Can you try to find the error in my code ? Ty Error in Chrome console when […]

By KylianTR
Categorized as angular, http, typescript Tagged , ,

Return string type from Spring Boot to Angular

I am trying to return a string value from Spring Boot to Angular but it gets an HttpErrorResponse when receives the value. I tried using integer type in spring and number type and in this way it works. Can anyone tell me what I’m doing wrong? Thank you. This is my code: login-form.component.ts: login() { […]

By luca
Categorized as angular, http, post, rest, spring-boot Tagged , , , ,

Typescript (Angular) – JSON model Deserialisation

I would like to add and populate additional fields (which are not sent by backend service) in my http model. Catch is that I am not able to populate (map) those fields in the place where http response is being received since I am using internal framework. Is there a possibility in Typescript (Angular) to […]

By patak
Categorized as angular, deserialization, http, json, typescript Tagged , , , ,

preflight request doesn’t pass access control check:

I am getting below error when trigger http call in angular Access to XMLHttpRequest at ‘loginapi’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. userdata(user: string): Observable<any> { const form = new FormData(); return this.http.put<any>(`/${user}`, form, […]

By Mani N
Categorized as angular, angular10, cors, http Tagged , , ,

Argument of type ‘any’ is not assignable to parameter of type ‘never’ — I always get this error by calling API in Angular 12

import { Component, OnInit } from ‘@angular/core’; import { PokemonserviceService } from ‘src/app/services/pokemonservice.service’; @Component({ selector: ‘app-observer’, templateUrl: ‘./observer.component.html’, styleUrls: [‘./observer.component.css’], }) export class ObserverComponent implements OnInit { constructor(private pokeService: PokemonserviceService) {} respArray: Array<any> = []; pokemonData: [] = [] as any; ngOnInit(): void { this.pokeService.getData().subscribe((resp) => { this.respArray = resp.results; resp.results.forEach((item: any) => { this.pokeService.getOtherData(item.url).subscribe( […]

By NullPointerException
Categorized as angular, api, http Tagged , ,

how to pass variable in http in angular 9

”’ how will i add fromDateTime and toDateTime as parameters to be passed in this link.”’ export function MSALInterceptorConfigFactory(): MsalInterceptorConfiguration { const protectedResourceMap = new Map<string, Array<string>>(); protectedResourceMap.set(‘,toDateTime=2019-12-01’, [‘CallRecords.Read.All’,’CallRecord-PstnCalls.Read.All’,’CallRecords.Read.All’]); return { interactionType: InteractionType.Redirect, protectedResourceMap }; } Source: Angular Questions

By mariafatima
Categorized as angular, angular9, http, typescript Tagged , , ,

Angular return typed promise from http request

At the moment, I’m trying to define interfaces for my Keycloak API requests in angular. But unfortunately, the response does not get the type which was declared… // interface export interface KeycloakToken { accessToken: string; expiresIn: number; refreshExpiresIn: number; refreshToken: string; tokenType: string; notBeforePolicy: number; sessionState: string; scope: string; } // request function private async […]

By Lukas Marschall
Categorized as angular, http, promise, typescript Tagged , , ,

Ending an AngularJS connection

How on earth do I do that with AngularJS? I’m using this code to generate a client side table with a search bar. ASP.NET MVC is the server here. app.controller(‘GenTable’, [‘$http’ ,’$scope’, ‘$window’, function($http ,$scope, $window) { console.log("I’m called"); $scope.CallSearch = function() { if($scope.SearchField==null) { $http.get("https://localhost:(portnumberhere)/project/all").then(function(response) { $window.Project =; ProjectLength = Project.length; console.log("I’m in […]

By user199135
Categorized as angularjs, connection, get, http, post Tagged , , , ,

Retrieve token (body) from spring with an angular(12) post

i’m trying to retrieve a token from my spring boot security application with an angular 12 frontend. When I try in postman i get my token but when i do the same with angular (12) i have an "undefined error". My response is in a Json body(with a refresh token in it) , not headers […]

By SlashUzero
Categorized as angular, http, spring-security Tagged , ,
1 2 3 61

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us