Category : angular-httpclient

I have a method that creates a new post. This post includes uploading a video. createPost(formDirective: FormGroupDirective): void { if ( this.postForm.valid && this.user?.fullName && this.user?.imageUrl && this.fileToUpload ) { const val = this.postForm.value; this.isLoading = true; var formData = new FormData(); formData.append(‘videoUrl’, this.fileToUpload, this.fileToUpload.name); formData.append(‘fullName’, this.user.fullName); formData.append(‘imageUrl’, this.user.imageUrl); formData.append(‘title’, val.title); this.postsService .createPostWithVideoUpload(formData) .subscribe((event) => ..

Read more

I am attempting to POST to an endpoint that requires arguments are passed as query string parameters and not via the POST body. const params = new HttpParams() .set(‘param1’, ‘1’) .set(‘param2’, ‘2’); const url = environment.apiUrl + ‘Service/Endpoint’; return this .httpClient .post<ServiceResponse>(url, { params }) .pipe(map(res => res.httpStatusCodeSuccess)); This is returning a 404 as the ..

Read more

I have a service response like below. "amount": 3330, "count": 56, "dataObjects": [ { "links": { "self": "http://localhost:4200/api/collection/" }, "id": "W391", "objectNumber": "IN-W391", "title": "Image 23", "webImage": { "guid": "89de22aa-e19f-4c83-87ff-26dd8f319c05", "width": 1200, "height": 800, "url": "http://localhost:4200/api/collection/7qzT0pbclLB7y3fdS1GxzMnV7m3gD3gWnhlquhFaJSn6gNOvMmTUAX3wVlTzhMXIs8kM9IH8AsjHNVTs8em3XQI6uMY=s0" } }, { "links": { "self": "http://localhost:4200/api/collection/" }, "id": "W391", "objectNumber": "IN-W391", "title": "Image 23", "webImage": { "guid": "89de22aa-e19f-4c83-87ff-26dd8f319c05", ..

Read more

I have an angular project in which i need to get a JSON from another server (SmartThings), so the simplest solution for me was to use HttpClient module in order to get this done, but when i try to do so, i get the next error: Access to XMLHttpRequest at ‘https://graph-na04-useast2.api.smartthings.com/api/smartapps/installations/locationId/data/?access_token=accessToken&callback=?’ from origin ‘http://localhost:4200’ has ..

Read more

I get this error 403 when I try to perform a simple POST request to my Spring Boot server from Angular client. HTML template <!– Create book html –> <div class="content-container"> <div class="content-area"> <!– Back button –> <div> <button class="btn btn-danger btn-block" (click)="back()">Back</button> </div> <p style="font-weight: bold; color: green;">Please enter all the details in-order to ..

Read more

i have some code i wrote that i am trying to test but i am unable to stub the responses in my tests constructor(private http: HttpClient) { } fetchApiCall(): Promise<ApiResponse> { const url = ‘www.google.com’; return this.http.get<ApiResponse>(url).toPromise().then((data) => { this.responseData = data; this.myObjects = this.assignObjectBasedOnResponse(this.responseData.version); return data; }).catch(() => { return this.responseData; }); } i ..

Read more

I have an issue in Angular whereby an implemented instance of HttpInterceptors declared in an Angular library is intercepting requests for HttpClient calls made outside the library (i.e. the consuming application). I am struggling to understand why this is happening. The HTTP_INTERCEPTOR injection is configured on the module declaration for my library, not my application. ..

Read more