SHARE
TWEET

Example Request

a guest Nov 22nd, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //.env or variable.js
  2. export const ENDPOINT = "https://app.moneyz.id/"
  3.  
  4. //network.js
  5. import { ENDPOINT } from '../variables';
  6. const BASE_URL = ENDPOINT+"api/v1/";
  7.  
  8. const get = (url) => {
  9.     return new Promise((resolve, reject) => {
  10.         axios.get(BASE_URL + url, {
  11.                 headers: {
  12.                     'Accept': 'application/json'
  13.                     //addmore header
  14.                 }
  15.             }).then(res => {
  16.                 resolve(res);
  17.             }).catch(err => {
  18.                 reject(err);
  19.             })
  20.     });
  21. }
  22.  
  23. //api.js
  24. import network from '../helpers/network';
  25. export function getProfile() {
  26.     return new Promise((resolve, reject) => {
  27.         network.get('profile').then((res) => {
  28.             resolve(res);
  29.         }).catch((err) => {
  30.             reject(err);
  31.         });
  32.     });
  33. }
  34.  
  35. //index.js
  36. import api from '../../../services/api';
  37. componentDidMount() {
  38.         this.getProfile();
  39.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top