No ‘Access-Control-Allow-Origin’ when call rest API

just write this on your function.php

add_filter( 'allowed_http_origin', '__return_true' );

tech