Skip to content

Instantly share code, notes, and snippets.

@Ackuq
Last active July 31, 2019 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ackuq/602314192eae6bc19022380cf10add6d to your computer and use it in GitHub Desktop.
Save Ackuq/602314192eae6bc19022380cf10add6d to your computer and use it in GitHub Desktop.
import base64 from 'react-native-base64';
...
const auth = base64.encode(`${Config.WP_USERNAME}:${Config.WP_PASSWORD}`);
export const updateData = async (route, data) => {
try {
fetch(Config.API_URL + route, {
method: 'POST',
headers: {
Authorization: `Basic ${auth}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
} catch (error) {
console.error(error);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment