Category : http

I have a json file like below: { "users": [ { id: person1 information: [ "first_name": "Mike", "last_name": "Patty", "address": ["address1","address2"] ] }, { id: person2 information: [ "first_name": "Tom", "last_name": "Jerry", "address": ["address1","address2"] ] }, ] } I would like to iterate users and add each user’s information to the API database. addInfo request ..

Read more

Suppose I have 5 directives (A,B,C,D,E) as components in AngularJS, all of these directives need the response data from one API, is there any method to call api once instead of calling API 5 times? I am trying to call api in controller and pass response to each directives by function call, but somehow it ..

Read more

In Angular, I run a simple GET request to the backend: some.component.ts this.dataService.runTask().subscribe( (data) => { this.output = data.body; this.modalService.showSuccess(‘Benchmark has been completed’); }, (error) => { this.modalService.showError(‘An unknown error has occurred’); } ); data.service.ts public runTask(): Observable<any> { return this.http.get(‘http://localhost:9001/tasks/1?type=1&n=100’, { observe: ‘response’ }); } It’s a call to the simple backend benchmark and ..

Read more

I’m trying to make an http api query call from my angular app. I have 2 parameters: URL & body that containing login_id, hash_id, company_num (TOKENS) how do i make this call. const httpOptions = { headers: new HttpHeaders({ "login_id": "*****", "login_hash": "*****", "login_company": "***" }) }; @Injectable({ providedIn: ‘root’ }) export class AccountService { ..

Read more

I added a new service in my Angular app: import { Injectable } from ‘@angular/core’; import { HttpClient } from ‘@angular/common/http’; import { Observable, Subscriber } from ‘rxjs’; @Injectable({ providedIn: ‘root’ }) export class IframeserviceService { constructor(private http: HttpClient) { } } and after successful compilation I get in the browser the error ERROR Error: ..

Read more

I’m trying to get data from a server but I’m not getting it. I leave the code below This is th interceptor function interceptor() { return { request: function (response) { console.log(‘GOOD REQUEST’); console.log(response.headers.Accept); if(response.headers.Accept === "application/json, text/plain, */*"){ var data = response; console.log(response); if(!data) { return $q.reject(response); } } return response; }, requestError: function ..

Read more

I have a entity with a Date property from package java.util. I store the entity in MySql with JPA. Java entity: @Entity public class Foo { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private Date date; } Storing entity method: @PostMapping("/foo") public Foo create(@RequestBody Foo foo) { foo.setDate(new Date()); return fooRepository.save(foo); } The request returns ..

Read more

Im trying to make a post to my api using a node server, i used the http class to make my headers but even after setting them (aparently corrected) im still getting an "Access-Control-Allow-Headers" what am i doing wrong This is my app.js (api): app.use((req, res, next) =>{ res.setHeader("Access-Control-Allow-Origin","*"); res.setHeader("Acces-Control-Allow-Headers","Access-Control-Request-Headers","Origin, X-Requested-With, Content-Type, Accept" ); res.setHeader("Acces-Control-Allow-Methods","GET, ..

Read more