BaseService.js 680 Bytes
import axios from 'axios'

export default class BaseService {
  constructor (resourcePath) {
    this.client = axios.create({
      baseURL: `http://localhost:8080/${resourcePath}`
    })
  }

  async get (url = '', config = {}) {
    const resp = await this.client.get(url, config)
    return resp.data
  }

  async post (url = '', body, config = {}) {
    const resp = await this.client.post(url, body, config)
    return resp.data
  }

  async put (url, body, config = {}) {
    const resp = await this.client.put(url, body, config)
    return resp.data
  }

  async delete (url, config = {}) {
    const resp = await this.client.delete(url, config)
    return resp.data
  }
}