Skip to content

Instantly share code, notes, and snippets.

View RubenPauwels1's full-sized avatar

Ruben Pauwels RubenPauwels1

View GitHub Profile
@RubenPauwels1
RubenPauwels1 / upload.js
Created March 4, 2020 11:05
Upload image to WordPress media library via REST api (React Native)
// Assuming image is coming from the openPicker method from ImagePicker (react-native-image-crop-picker)
// Auth via JWT Token.
export function uploadMedia(image, token) {
return new Promise(async (resolve, reject) => {
var myHeaders = new Headers();
myHeaders.append("Authorization", `Bearer ${token}`);
myHeaders.append("Content-Type", "multipart/form-data;");