Created
June 1, 2019 10:33
-
-
Save madan712/3021ded47ad96ed3cceaa8e865966e33 to your computer and use it in GitHub Desktop.
AppApi.js - Example with React, Redux and Axios API
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'; | |
class AppApi { | |
static sayHello(name) { | |
return new Promise((resolve, reject) => { | |
const url = 'http://localhost:8080/sayhello'; | |
axios.get(url, { params: { name: name } }).then(response => { | |
console.log(response); | |
resolve(response.data); | |
}).catch(error => { | |
reject(error.response); | |
}); | |
}); | |
} | |
} | |
export default AppApi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment