koltyakov / sp-rest-proxy

🌐 SharePoint API Proxy for local development
MIT License
172 stars 43 forks source link

About loadPageContext #92

Closed hasankoroglu closed 4 years ago

hasankoroglu commented 4 years ago

Hi @koltyakov,

As you suggested, i'm trying to use loadPageContext. My app runs on localhost:3000 and sp-rest-proxy runs on 8080 port. when i run my app, loadPageContext function tries to get data from localhost:3000/api/web... And it gives 404 error. What am i doing wrong? My public code is here: https://github.com/hasankoroglu/sp-pnp-js Sorry for bothering you with this simple issue :(

koltyakov commented 4 years ago

You're calling loadPageContext(); without waiting when it is resolved. Should be thenable logic or awaiting. After, it's a good thing to check what's in _spPageContextInfo.webAbsoluteUrl property.

hasankoroglu commented 4 years ago

I think, i could not explain my problem clearly :( when i call the loadPageContext function, it is sending the request to the localhost:3000 (CRA dev server), but sp-rest-proxy runs on localhost:8080.

koltyakov commented 4 years ago

Do you have "proxy": "http://localhost:8080", in package.json? Details. CRA proxies to the proxy, sp-rest-proxy adds auth and proxies to SharePoint. And too many proxy words in that sentence. :D

hasankoroglu commented 4 years ago

Thankx, thanx and thanx again. It's all about my missing information and missing learning :(