I am sending a request to my codegniter app. When I vardump the object it clearly says its an object with a property name of subtotal. But when i try to access the property i get the error message "Trying to get property 'subtotal' of non-object"
This only happens with code igniter 4 and not 3. Not really sure why. Below is the code i am using. Any help would be really appreciated.
public function get_sales_tax(){
$object = json_decode(file_get_contents("php://input"));
var_dump($object->subtotal);
}
erorr message
CRITICAL - 2021-03-13 13:37:39 --> Trying to get property 'subtotal' of non-object #0 /Applications/MAMP/htdocs/simplemenu-all-stores/project-root/app/Controllers/Home.php(43): CodeIgniter\Debug\Exceptions->errorHandler(8, 'Trying to get p...', '/Applications/M...', 43, Array) #1 /Applications/MAMP/htdocs/simplemenu-all-stores/project-root/vendor/codeigniter4/framework/system/CodeIgniter.php(918): App\Controllers\Home->get_sales_tax() #2 /Applications/MAMP/htdocs/simplemenu-all-stores/project-root/vendor/codeigniter4/framework/system/CodeIgniter.php(404): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Home)) #3 /Applications/MAMP/htdocs/simplemenu-all-stores/project-root/vendor/codeigniter4/framework/system/CodeIgniter.php(312): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false) #4 /Applications/MAMP/htdocs/simplemenu-all-stores/project-root/public/index.php(45): CodeIgniter\CodeIgniter->run() #5 {main}