datarest.js 417 B

123456789101112131415161718192021
  1. import { HTTP } from './http-axios'
  2. export default {
  3. getPosts (cb) {
  4. HTTP.get('posts')
  5. .then(response => {
  6. console.log('response', response)
  7. cb(response.data)
  8. })
  9. },
  10. getPost (id, cb) {
  11. HTTP.get(`posts/` + id)
  12. .then(response => {
  13. console.log('response', response)
  14. cb(response.data)
  15. })
  16. .catch(e => {
  17. this.errors.push(e)
  18. })
  19. }
  20. }