Skip to content

Instantly share code, notes, and snippets.

@YEK-PLUS
Created September 23, 2019 18:51
Show Gist options
  • Save YEK-PLUS/648484896b6fc14c39e5b5fcb0946f64 to your computer and use it in GitHub Desktop.
Save YEK-PLUS/648484896b6fc14c39e5b5fcb0946f64 to your computer and use it in GitHub Desktop.
api using
import { TryLogin } from './user';
const Login = async (username,password) => {
const response = await UserDetails(username,password);
return response;
};
export default { Login };
import axios from 'axios';
export const instance = axios.create({
baseURL: 'http://159.146.28.45:8080/',
timeout: 5000,
});
export default async (type, path, body,header) => {
console.log(body);
const r = await instance.post(path, body, header);
return r;
};
instance.interceptors.response.use(
(response) => (response.data),
(error) => {
const code = error.response && error.response.data;
return (code);
},
import API from './index';
export const TryLogin = async (username,password) => {
const response = await API('post', '/user/login', { username,password });
return response;
};
export default { TryLogin };
import {Login} = './helper';
const Response = async (username,password,callback) => {
const res = await Login(username,password);
return callback(res);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment