Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your
needs please complete the below template to ensure we have the details to help. Thanks!
Please check out the Docs to see if your question is already addressed there. This will help us ensure our documentation covers the most frequent questions.
Please specify what version of the library you are using: [ 1.2.1 ]
Please specify what version(s) of SharePoint you are targeting: [ 1.6.0 ]
My project works great on my work bench. When I try and deploy it to our tenant, it starts throwing errors.
public getLocations(): Promise<ILocation[]> {
console.log("LocationServices | getLocations | fired");
return sp.web.lists.ensure(DELIVERY_BOARD_NAME)
.then((ler: ListEnsureResult): Promise<any> => {
console.log("LocationServices | getLocations | ensure complete");
if (ler.created) {
let batchCreate = sp.web.createBatch();
ler.list.fields.inBatch(batchCreate).addText('Abbreviation');
return batchCreate.execute()
.then((): Promise<any> => {
let batchDisplay = sp.web.createBatch();
let view = ler.list.defaultView;
view.fields.inBatch(batchDisplay).add('Abbreviation');
return batchDisplay.execute();
})
.then(() => ler.list.items.select("Title", "Abbreviation", "Id").get());
} else {
return ler.list.items.select("Title", "Abbreviation", "Id").get();
}
})
.catch((error) => {
console.log("LocationServices | getLocations | error: ", error);
})
}
When I run it on a production site, I get:
LocationServices | getLocations | fired
/sites/deployedSite/SitePages/_api/web/lists:1 Failed to load resource: the server responded with a status of 404 ()
my-web-part_296a730be8d03ebb8e5ca894f4c1a0a1.js:118 Uncaught (in promise) Error: Error making HttpClient request in queryable: [404] ::> SyntaxError: Unexpected end of JSON input
at my-web-part_296a730be8d03ebb8e5ca894f4c1a0a1.js:118
In the network tab, I see 2 404 errors;
https://i.imgur.com/aHiAeUp.png (I don't know how to display the image, sorry)
The first one is I assume checking if the list exists, and the second is trying create the list:
https://i.stack.imgur.com/qpRO2.png
I have full permissions for the site.
I also tried switching the ensure to add but that failed also.
Did you remember to set the context? That is the most common cause for this. The global var exists on the workbench but not in the closure of the loaded web part. Let us know if that helps or not. Thanks!
That was it, thank you!
Thanks!