How to consume a gateway private api from a JS application

How can you consume a rest private api wrapped in a vpc… I have setup a private api that returns data from my db… When I test the api in the gateway console everything is working perfect… However I need this end point to be use in a Javascript fetch function in my application. When I try to fetch the data it kicks me out… Not working. I have also tried to attach the vpc number inside the url but nothing worked… Any help would be great