Why is my pickup availability function showing a bad request error?

I have a js function on variant change. which fetches data for pickup availability ( It is present on the Shopify documentation : https://shopify.dev/themes/delivery-fulfillment/pickup-availability#the-javascript-function )

But everytime I select a variant it shows me a bad request error in the console.

GET http://127.0.0.1:9292/variants/[variant-id]/?section_id=pickup-availability 400 (Bad Request);

Any help would be much appreciated.