mirror of https://github.com/doccano/doccano.git
pythondatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learningannotation-tool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
932 B
48 lines
932 B
import axios from 'axios'
|
|
|
|
class ApiService {
|
|
constructor() {
|
|
this.instance = axios.create({
|
|
baseURL: process.env.baseUrl
|
|
})
|
|
}
|
|
|
|
setHeader(token) {
|
|
this.instance.defaults.headers.common.Authorization = `Token ${token}`
|
|
}
|
|
|
|
removeHeader() {
|
|
this.instance.defaults.headers.common = {}
|
|
}
|
|
|
|
request(method, url, data = {}, config = {}) {
|
|
return this.instance({
|
|
method,
|
|
url,
|
|
data,
|
|
...config
|
|
})
|
|
}
|
|
|
|
get(url, config = {}) {
|
|
return this.request('GET', url, {}, config)
|
|
}
|
|
|
|
post(url, data, config = {}) {
|
|
return this.request('POST', url, data, config)
|
|
}
|
|
|
|
put(url, data, config = {}) {
|
|
return this.request('PUT', url, data, config)
|
|
}
|
|
|
|
patch(url, data, config = {}) {
|
|
return this.request('PATCH', url, data, config)
|
|
}
|
|
|
|
delete(url, data, config = {}) {
|
|
return this.request('DELETE', url, data, config)
|
|
}
|
|
}
|
|
|
|
export default new ApiService()
|