I have created a module for checkout payment methods event. But I need to check request is getting from web or rest API.
I mean something like:
if(request from rest API)
{
echo "REST API";
}
else
{
echo "WEB";
}
Please Help me
-
Why do you want to distinct these two?Bartosz Herba– Bartosz Herba2017年11月28日 08:04:38 +00:00Commented Nov 28, 2017 at 8:04
1 Answer 1
You can use Magento\Framework\App\State::getAreadCode() to check the request is from web or API. If the request is from API, this will return "webapi_rest" or "webapi_soap". If the request is from web, this will return "frontend".
-
can you help to find out rest api get products 404 page error : magento.stackexchange.com/q/246597/57334 @PY Yickzus– zus2018年10月17日 07:31:19 +00:00Commented Oct 17, 2018 at 7:31
Explore related questions
See similar questions with these tags.