devoooo4u / spfx-task-list-web-part

8 stars 7 forks source link

SPHttpClient.configurations.v1 #1

Closed MartinSabacky closed 6 years ago

MartinSabacky commented 6 years ago

Argument of type 'import("c:/Users/sabacky/Documents/sama/sharepoint/code/pokus/spfx-task-list-web-part/node_modules/@microsoft/sp-http/lib/spHttpClient/SPHttpClientConfiguration").default' is not assignable to parameter of type 'import("c:/Users/sabacky/Documents/sama/sharepoint/code/pokus/spfx-task-list-web-part/node_modules/@microsoft/sp-webpart-base/node_modules/@microsoft/sp-http/lib/spHttpClient/SPHttpClientConfiguration").default'. Property 'flags' is protected but type 'SPHttpClientConfiguration' is not a class derived from 'SPHttpClientConfiguration'. (alias) class SPHttpClient import SPHttpClient SPHttpClient is used to perform REST calls against SharePoint. It adds default headers, manages the digest needed for writes, and collects telemetry that helps the service to monitor the performance of an application.

For communicating with non-SharePoint services, use the HttpClient class instead.

@public

americo2015 commented 6 years ago

Do you have some example for non programmer to change from SPHttpClient to HttpClient?

devoooo4u commented 6 years ago

Thank you for the response @MartinSabacky .. But in this case we are using the SharePoint REST calls and we do need the management of default headers , digest etc. Thus, the use of spHttpClient is justified. The real problem exists elsewhere. It is with the version of SPHttpClient and its dependency on the project. The version of @microsoft/sp-http' is not compatible with other microsoft packages. @americo2015 you can try these approaches to resolve your issue:

  1. Update the package.json file and fill in the latest version of SPHTTPClient. Post this, try reinstalling the node_modules packages. If this leads to some other Error then try #2
  2. Create a Fresh SP Project using yomen template generator and then copy the node_modules folder content to the existing TaskListwebPart peoject. and then run gulp serve. PS: Refer this Issue thread raised to microsoft.
americo2015 commented 6 years ago

Thanks! It seems to be working now by creating an bran new project and updating the package.json to add knoclout, datatables, etc. After I ran npm i I copied the node_modules folder to the task_list project and I ran gulp serve.

Update: after testing the app both in workbench and installed on SP Online I noted that the array "asd[]" is not getting filled with the lists name, it is allways empty and as result the dropdown in the property pane is empty.

I have a normal list and a task list in the site but they doesn't appears. What can be the problem?

Update 2: I think I foud the problem: it is the BaseTamplate number. I tested changing it to 100 and I get the normal list nad when using 171 I get the task list. I checked the BaseTemplate numbers and I couldn't find the 107, which template is that?

devoooo4u commented 6 years ago

Hi @americo2015 , template ID 107 is for Task List. And this project deals with task list only as Microsoft is yet to release TASK lists as a web part in Modern site pages

p1995 commented 4 years ago

Hi, I cloned the project solution from my office system to github, installed all the required packages and ran gulp serve. There are more than 10 projects inside the solution. I had no such issues until I created a new project. I started getting this error for all older webparts wherever I used sphttpclient. So what would be the best solution?