Skip to content

Commit 6c474ce

Browse files
committed
refactor: VideoPress utilizes the @wordpress/api-fetch utility
Utilize the `@wordpress/api-fetch` utility to align with WordPress core and enable usage of its functionality. Namely, leveraging middleware for configuring requests.
1 parent ac4c623 commit 6c474ce

File tree

1 file changed

+8
-1
lines changed
  • projects/packages/videopress/src/client/lib/get-media-token

1 file changed

+8
-1
lines changed

projects/packages/videopress/src/client/lib/get-media-token/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* External dependencies
33
*/
4+
import apiFetch from '@wordpress/api-fetch';
45
import debugFactory from 'debug';
56
/**
67
* Internal dependencies
@@ -80,7 +81,13 @@ const requestMediaToken = function (
8081
break;
8182
}
8283

83-
fetch( adminAjaxAPI, {
84+
const urlOrPath = /^https?:\/\//.test( adminAjaxAPI )
85+
? { url: adminAjaxAPI }
86+
: { path: adminAjaxAPI };
87+
88+
apiFetch( {
89+
...urlOrPath,
90+
parse: false,
8491
method: 'POST',
8592
credentials: 'same-origin',
8693
body: new URLSearchParams( fetchData ),

0 commit comments

Comments
 (0)