angular http請求頭部信息設置


1、一個

    const headers = new Headers({
      'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      'Accept': '*!/'
    });
    const params = 'username=' + data.username + '&password=' + data.password + '&key=' + data.key + '&verifyCode=' + data.verifyCode;
    return this.ht.post(`${this.config.urlauth}/login`, params, {headers: headers}).map(value => value);

2、多個

httpOptions = {
  headers: new HttpHeaders().set('Content-Type', 'application/json')
  .set('Content-Type', 'application/x-www-form-urlencoded')
}

3、HttpHeaders

const headers = new HttpHeaders({
      'Content-Type': 'application/json'
    });
    const url= ``;
    return this.http.post(url,null,{headers: headers}).pipe(
        map(res=>res)
    )


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM