Commit d690216a authored by Anton's avatar Anton

Prevent error when empty response for PBA titles

parent db173b09
Pipeline #20041 passed with stage
in 2 minutes and 17 seconds
......@@ -27,8 +27,10 @@ const vocabularies = {
let pieces = []
try {
const result = await axios.get(`${process.env.API_HOST}/pba/pieces`, {headers})
pieces = result.data.sort((a, b) => a.label.replace(/\W/g, '').localeCompare(b.label.replace(/\W/g, '')))
if (limit) pieces = pieces.splice(0, limit)
if (Array.isArray(result.data)) {
pieces = result.data.sort((a, b) => a.label.replace(/\W/g, '').localeCompare(b.label.replace(/\W/g, '')))
if (limit) pieces = pieces.splice(0, limit)
}
}
catch (err) {
console.error('Failed to load PBA vocabularies:', err.message || err.code)
......
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