Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import axios from 'axios';
- const RootPath = 'http://192.168.100.11:5000';
- const RootPathTwo = 'https://api.myjson.com';
- const Get = path => {
- const promise = new Promise((resolve, reject) => {
- axios.get(`${RootPath}/${path}`).then(
- response => {
- resolve(response.data);
- },
- err => {
- reject(err);
- },
- );
- });
- return promise;
- };
- const GetTwo = path => {
- const promise = new Promise((resolve, reject) => {
- axios.get(`${RootPathTwo}/${path}`).then(
- result => {
- resolve(result.data);
- },
- err => {
- reject(err);
- },
- );
- });
- return promise;
- };
- const Post = (path, data) => {
- const promise = new Promise((resolve, reject) => {
- axios.post(`${RootPath}/${path}`, data).then(
- result => {
- resolve(result);
- },
- err => {
- reject(err);
- },
- );
- });
- return promise;
- };
- // get
- const getData = () => Get('api/jobs');
- const getProfile = () => Get('api/profile');
- const getResetPassword = data => Get('api/api/driver/users/reset/' + data);
- const getNotification = () => GetTwo('bins/1cmvll');
- // post
- const postLogin = data => Post('api/driver/users/login', data);
- const postRegister = data => Post('api/driver/users/create', data);
- const postForgotPassword = data => Post('api/driver/users/forgot', data);
- const postResetPassword = (url, data) =>
- Post('api/driver/users/reset/' + url, data);
- const API = {
- getData,
- getProfile,
- getNotification,
- getResetPassword,
- postLogin,
- postRegister,
- postForgotPassword,
- postResetPassword,
- };
- export default API;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement