Commit 5a0309ba authored by Anton's avatar Anton

Do not perform pba vocabulary requests if not configured

parent 0ac37aba
...@@ -15,18 +15,22 @@ class PBA extends TinyEmitter { ...@@ -15,18 +15,22 @@ class PBA extends TinyEmitter {
} }
async _performRequest (path) { async _performRequest (path) {
const result = await axios.get(`${config.pba.baseUrl}/${path}`, { auth: config.pba.credentials }) if (config.pba.baseUrl) {
return result.data const result = await axios.get(`${config.pba.baseUrl}/${path}`, { auth: config.pba.credentials })
return result.data
}
} }
async getPiecesHandler (req, res) { async getPiecesHandler (req, res) {
const result = await this._performRequest('pieces') const result = await this._performRequest('pieces')
this._response(req, res, result.pieces) if (result) this._response(req, res, result.pieces)
else this._errorResponse({}, 503, 'PBA vocabularies not available')
} }
async getTitlesForPieceHandler (req, res) { async getTitlesForPieceHandler (req, res) {
const result = await this._performRequest(`titles/${req.params.piece_id}`) const result = await this._performRequest(`titles/${req.params.piece_id}`)
this._response(req, res, result.titles) if (result) this._response(req, res, result.titles)
else this._errorResponse({}, 503, 'PBA vocabularies not available')
} }
_response (req, res, data = {}) { _response (req, res, data = {}) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment