Skip to content

Instantly share code, notes, and snippets.

@gtalarico
Created June 7, 2019 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtalarico/2e7bb6f4227a26d65611d49b9782300e to your computer and use it in GitHub Desktop.
Save gtalarico/2e7bb6f4227a26d65611d49b9782300e to your computer and use it in GitHub Desktop.
Netlify Lambda Service
// lambdaService.js
import axios from 'axios'
const $axios = axios.create({
baseURL: '/.netlify/functions',
timeout: 10000 // 10 seconds
})
// Response Interceptor to handle and log errors
$axios.interceptors.response.use(
function(response) {
return response
},
function(error) {
return Promise.reject(error)
}
)
export default {
fetchRecords() {
return $axios.get('airtable').then(response => {
return response.data
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment