I received a POST request from my payment gateway with the following form data:
Upon trying to fetch the data using the code snippet below, I encountered errors and gibberish content:
this.http
.post<any>('https://xyz.app/test', {
title: 'Testing...',
})
.subscribe((data) => {
console.log(data);
});
The error message displayed is as follows:
Unexpected error occurred
{
"headers": {
"normalizedNames": {},
"lazyUpdate": null
},
"status": 200,
"statusText": "OK",
"url": "https://xyz.app/test",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure during parsing for https://xyz.app/test",
"error": {
"error": {},
"text": "<!DOCTYPE html><html lang=\"en\">
...
// (content truncated)
}
}
In addition, there is another error:
ERROR
ke {headers: E, status: 200, statusText: 'OK', url: 'https://xyz.app/test', ok: false, …}
error: {error: SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>)...
// (further details omitted for brevity)
Given the PHP code snippet provided by the payment gateway for verification purposes, how can I successfully retrieve and display the payment transaction data?
Here is the PHP code:
<?php
// PHP code snippet here
?>