Category : httpclient

from my app I want to reach an api. The curl request: curl –request POST https://… –header ‘Authorization: Token …’ –header ‘Accept: application/csv’ –header ‘Content-type: application/vnd.flux’ –data ‘…’ works and returns data from an InfluxDB instance. The problem ist when I try everithing in ANgular: I set up an proxy which redirects orrectly the requests ..

Read more

i need to get X-Token from headers when my backend API server response. So this is my response, see it with chrome dev tool As you can see the response have X-Token, but, from my code i can’t read it, my typescript code: this.httpClient.post(ConfigUtils.endpointApi, this.usrUser, { observe: ‘response’ }) .subscribe(ret => { console.log(‘token: ‘, ret); ..

Read more

I want to convert complex request objects to queryString like format for posting the formData with content type as x-www- form-urlencoded . My object would be of format const obj= { "Employee": { "Id": 123, "Settings": { "StartOfDayType": [ 1 ], "EndOfDayType": [ 2 ], "workSettings": { "WorkStartTime": "{"Ticks":288000000000,"Days":0,"Hours":8,"Milliseconds":0,"Minutes":0,"Seconds":0,"TotalDays":0.33333333333333331,"TotalHours":8,"TotalMilliseconds":28800000,"TotalMinutes":480,"TotalSeconds":28800}", "WorkEndTime": "{"Ticks":648000000000,"Days":0,"Hours":18,"Milliseconds":0,"Minutes":0,"Seconds":0,"TotalDays":0.75,"TotalHours":18,"TotalMilliseconds":64800000,"TotalMinutes":1080,"TotalSeconds":64800}", }, "StartLocation": { "Latitude": ..

Read more

import { Component, OnInit } from ‘@angular/core’; import { Players } from ‘./players’ import { HttpClient } from ‘@angular/common/http’ @Component({ selector: ‘app-json-with-search’, templateUrl: ‘./json-with-search.component.html’, styleUrls: [‘./json-with-search.component.scss’] }) export class JsonWithSearchComponent implements OnInit { player: Players[]; constructor( private http:HttpClient) { } ngOnInit(): void { this.http.get(‘/sample.json’).subscribe((result)=> { //this.player = result; console.log(result) }, (error)=> { console.log(error) }) } ..

Read more

I’m trying to send a zip file to a backend(Springboot) with Angular 10.I am getting a 401 error and Current request is not of type [org.springframework.web.multipart.MultipartHttpServletRequest at the server side. I tried to change the Content-Type using headers.set(‘Content-Type’,’multipart/form-data’) I see the Content-Type changed to multipart/form-data when I print the header options before the post request ..

Read more

I am using an Angular material table, I try to edit the data for one row in the table and save it in the database by using HttpClient, the data is from dataSource. When I click on the edit button(add-person.component.html), it would call "row.confirmEditCreate_AddPerson()" and pass the "this" data (row data) (on table-element.ts), my question ..

Read more