-
Go to any SPFX webpart directory. For this example, I'll be using
SPFXHeader
.
cd SPFXHeader
-
Install dependancies.
npm install
-
Serve app using Terminal.
gulp serve --nobrowser
-
Then use your internet browser to visit your respective online workbench.
https://<TENANT NAME>.sharepoint.com/sites/<SITEPAGE>/_layouts/15/workbench.aspx
- Copy code below and replace old codes in
axios-license.ts
import axios from "axios";
const instance = axios.create({
baseURL:
"https://firestore.googleapis.com/v1/projects/srkklicense/databases/(default)/documents/"
});
export default instance;
- Copy code below and replace old
checkLicenseActive()
method only. In this case, the method can be found inRyanHeader.tsx
.
checkLicenseActive = () => {
const tenantUrl = this.props.siteCollectionUrl.split("/")[2];
axios
.get("/tenants")
.then(res => {
Object.keys(res.data.documents).map(k => {
//? Object.keys returns an array of object keys
let obj = res.data.documents[k];
if (obj.fields.tenant.stringValue === tenantUrl) {
console.log(
"isLicenseActive",
obj.fields.isLicenseActive.stringValue
);
this.setState({
isLicenseActive: obj.fields.isLicenseActive.stringValue //? This is pretty pointless. It's more prepare for the future if using seperate database for key auth.
});
}
}); //? Extract object to put in array of object
})
.catch(error => console.log(error));
};
- Run commands in Terminal
gulp clean
gulp bundle --ship
gulp package-solution --ship
- The
.sppkg
file will appear in your/sharepoint/solution/xxx.sppkg
directory