Skip to content

Instantly share code, notes, and snippets.

@madan712
Created June 1, 2019 10:33
Show Gist options
  • Save madan712/3021ded47ad96ed3cceaa8e865966e33 to your computer and use it in GitHub Desktop.
Save madan712/3021ded47ad96ed3cceaa8e865966e33 to your computer and use it in GitHub Desktop.
AppApi.js - Example with React, Redux and Axios API
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