简体   繁体   中英

How to Send timezone info to server with http request?

I would like to do some timezone specific date manipulation on server. But I don't want to send the timezone via request payload for each and every http request. Any other work around there for achieve this? I use asp.net Web API for backend and Angular 2 for front end.

To add a header to a specific request:

var headers = new Headers();
headers.append('MyHeaderName','MyHeaderValue')
http.post('http://myurl', {/*body*/}, { headers: headers })

Alternatively, you could extend the http class and add a header to every request automatically, see here for details:

What is httpinterceptor equivalent in angular2?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM