SharePoint / PnP-JS-Core

Code moved to https://github.com/pnp/pnpjs. This repository is archived.
Other
379 stars 231 forks source link

Get SP web using PnP JS from a plain html file #791

Closed HelloPnP closed 6 years ago

HelloPnP commented 6 years ago

I've included the pnp js file from a file system path and then referring it to html file but i'm unable to get the sp web object. here is my code in html head tag

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="C:/work/pnp.js"></script>
<script>
    var webUrl = "http://serverName:2016";

    $(document).ready(function() {
        var web = new Web(webUrl);       
        console.log(web);   

        web.lists.getByTitle("Employee").items.select("Title").get().then((items: any[]) => {
                    console.log(items);
        }); 

        var web = $pnp.sp.web(webUrl);//web is undefined
    }); 
</script>
</head>
koltyakov commented 6 years ago

Local resource can't be used <script src="C:/work/pnp.js"></script>. A script should be hosted on the web (locally in SP, CDN, etc.). Closing this issue as not related to the library at all.