jscdn.ink/dist/lib/fetch.js

16 lines
319 B
JavaScript
Raw Normal View History

2023-01-14 16:49:53 +08:00
import fetch from 'fetch'
2023-04-21 10:53:54 +08:00
fetch.BASE_URL = '//api.jscdn.ink'
2023-01-14 16:49:53 +08:00
fetch.inject.request(function (conf) {
2023-01-16 18:17:30 +08:00
var token = localStorage.getItem('token')
2023-01-14 16:49:53 +08:00
conf.headers['content-type'] = 'application/json'
2023-01-16 18:17:30 +08:00
if (token) {
conf.headers.authorization = token
}
2023-01-14 16:49:53 +08:00
})
fetch.inject.response(r => r.json())
export default fetch