Created
July 8, 2020 14:37
-
-
Save jmichaelward/7f0397ba2d43cebd76dd109f3108d30d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global wp, myPlugin */ | |
const { | |
apiFetch | |
} = wp; | |
const postMyData = () => { | |
apiFetch.use( apiFetch.createNonceMiddleware( myPlugin.nonce ) ); | |
apiFetch( | |
{ | |
path: 'myPlugin/v1/myEndpoint', | |
method: 'POST', | |
data: { myDataPoint: 'somestring' } | |
} | |
) | |
.then( result => { | |
// Do something with the result | |
} ) | |
.error( error => { | |
// Do something with the error | |
} ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment