| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Refresh nonce if authentication fails |
| | | */ |
| | |
| | | 'X-WP-Nonce': this.getNonce() |
| | | }; |
| | | |
| | | const response = await fetch(url, { |
| | | if (!isFormData && typeof options.body === 'object' && !Object.hasOwn(options.body, 'user')) { |
| | | options.body.user = this.getUser(); |
| | | } |
| | | |
| | | let obj = { |
| | | ...options, |
| | | credentials: 'same-origin', |
| | | headers |
| | | }); |
| | | }; |
| | | |
| | | if (!isFormData && typeof obj.body === 'object') { |
| | | |
| | | obj.body = JSON.stringify(obj.body); |
| | | } |
| | | |
| | | const response = await fetch(url, obj); |
| | | |
| | | if ((response.status === 403 || response.status === 401) && retryCount === 0) { |
| | | const result = await response.clone().json(); |