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