Accessing raspberrypi.local from Nodemcu
In order to access the API, your NodeMCU needs to know the IP address your Pi has at this time. There are several ways to resolve raspberrypi.local to the actual IP. Assuming the NodeMCU got its IP assigned by your WiFi hotspot, it also received a DNS server IP. This is where the NodeMCU would ask first. However, if this DNS server is hosted by your internet provider, it obviously would not know what to respond when asked for your raspberrypi.local.

Another way, especially for .local domains, is mDNS. NodeMCU has a module to do that.

If you work with this a lot, consider running a local development network with your own DHCP/DNS combo. dnsmasq is a good place to start. Lots of tutorials online. The Pi can host that for you.