File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -187,16 +187,26 @@ export default class WooCommerceRestApi {
187187 _request ( method , endpoint , data , params = { } ) {
188188 const url = this . _getUrl ( endpoint , params ) ;
189189
190+ const headers = {
191+ Accept : "application/json"
192+ } ;
193+ // only set "User-Agent" in node environment
194+ // the checking method is identical to upstream axios
195+ if (
196+ typeof process !== "undefined" &&
197+ Object . prototype . toString . call ( process ) === "[object process]"
198+ ) {
199+ headers [ "User-Agent" ] =
200+ "WooCommerce REST API - JS Client/" + this . classVersion ;
201+ }
202+
190203 let options = {
191204 url : url ,
192205 method : method ,
193206 responseEncoding : this . encoding ,
194207 timeout : this . timeout ,
195208 responseType : "json" ,
196- headers : {
197- "User-Agent" : "WooCommerce REST API - JS Client/" + this . classVersion ,
198- Accept : "application/json"
199- }
209+ headers
200210 } ;
201211
202212 if ( this . isHttps ) {
You can’t perform that action at this time.
0 commit comments