본문 바로가기

Dev/angular

'Content-Type': 'application/x-www-form-urlencoded', angular post

 const headers = new HttpHeaders({
      'Content-Type': 'application/x-www-form-urlencoded',
      apiKey: '어쩌구저쩌구'
    });
    
    const body = new URLSearchParams();
    body.set('키1', '값1');
    body.set('키2', '값2');
   
    return this.http.post<any>('https://api.adress.co.kr:port/rest/path',
      body.toString(), {headers});
  }

 

이런식으로 하면 된다