Created
September 23, 2019 18:51
-
-
Save YEK-PLUS/648484896b6fc14c39e5b5fcb0946f64 to your computer and use it in GitHub Desktop.
api using
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TryLogin } from './user'; | |
const Login = async (username,password) => { | |
const response = await UserDetails(username,password); | |
return response; | |
}; | |
export default { Login }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import API from './index'; | |
export const TryLogin = async (username,password) => { | |
const response = await API('post', '/user/login', { username,password }); | |
return response; | |
}; | |
export default { TryLogin }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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