Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.router.get('/:id', this.controller.show.bind(this.controller));
- public async show(req: Request, res: Response): Promise<any> {
- const params = req.params;
- const token = req.headers.token;
- let transaction;
- try {
- transaction = await this.transactionRepo.getTransactionResult(params.id, token);
- console.log("instead carries on here"); // 2
- if (transaction.success === false) {
- return res.status(404).json({
- success: false,
- status: 404,
- data: transaction,
- message: "Failed to retrieve transaction result"
- });
- }
- return res.status(200).json({
- success: true,
- status: 200,
- data: transaction,
- message: "Successfully retrieved transaction result"
- });
- } catch (err) {
- //console.log("Does not call this");
- return res.status(500).json({
- success: false,
- status: 400,
- data: err,
- message: "The server threw an unexpected error",
- });
- }
- public async getTransactionResult(transactionId: string, token: string) {
- const url = this.config.api_url + "/api/transactions/" + transactionId + "/summary";
- const options = {
- uri: url,
- headers: {
- 'token': token
- },
- body: {
- },
- json: true,
- resolveWithFullResponse: true
- }
- let result;
- try {
- result = await request.get(options);
- if (result.statusCode !== 200) {
- return { "success": false, data: result }
- }
- return { "success": true, data: result }
- } catch (err) {
- console.log("CAUGHT ERROR"); // 1
- return err;
- }
- }
Add Comment
Please, Sign In to add comment