Added try/catch to mastodon micro-service
This commit is contained in:
parent
b6630790cc
commit
2e4af394f9
|
@ -4,12 +4,22 @@ import { Request, Response } from 'express'
|
||||||
|
|
||||||
export default class MastodonController extends MastodonService {
|
export default class MastodonController extends MastodonService {
|
||||||
public fetchMastodonProfile = async (req: Request, res: Response) => {
|
public fetchMastodonProfile = async (req: Request, res: Response) => {
|
||||||
const data = await this.getMastodonProfile()
|
try{
|
||||||
return res.send(makeResponse(data))
|
const data = await this.getMastodonProfile()
|
||||||
|
return res.send(makeResponse(data))
|
||||||
|
}
|
||||||
|
catch (err: any){
|
||||||
|
res.send(makeResponse(err.message, {}, 'Failed', true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public fetchMastodonStatuses = async (req: Request, res: Response) => {
|
public fetchMastodonStatuses = async (req: Request, res: Response) => {
|
||||||
const data = await this.getMastodonStatuses()
|
try {
|
||||||
return res.send(makeResponse(data))
|
const data = await this.getMastodonStatuses()
|
||||||
|
return res.send(makeResponse(data))
|
||||||
|
}
|
||||||
|
catch (err: any) {
|
||||||
|
res.send(makeResponse(err.message, {}, 'Failed', true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,10 @@ export default class MastodonService {
|
||||||
|
|
||||||
public getMastodonStatuses = async () => {
|
public getMastodonStatuses = async () => {
|
||||||
const { data } = await axiosInstance.get(
|
const { data } = await axiosInstance.get(
|
||||||
'https://fosstodon.org/api/v1/accounts/109612266657666903/statuses'
|
'https://fosstodon.org/api/v1/accounts/109612266657666903/statuses',
|
||||||
|
{
|
||||||
|
timeout: 10000
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue