5 thoughts on “Fixing CORS Errors in SPFx with Azure Functions”
i tried code which you provided. but it is gives following error message.
TypeError: Failed to fetch
at FetchProvider.UE6e.FetchProvider.fetch (sp-webpart-workbench-assembly_en-us.js:49867)
at Function.8Y7G.HttpClientHelper.fetchCore (sp-webpart-workbench-assembly_en-us.js:48803)
at HttpClient.LJZb.HttpClient._fetch (sp-webpart-workbench-assembly_en-us.js:49488)
at HttpClient.LJZb.HttpClient.fetch (sp-webpart-workbench-assembly_en-us.js:49456)
at HttpClient.LJZb.HttpClient.get (sp-webpart-workbench-assembly_en-us.js:49469)
at SpfxCors. (SpfxCors.tsx:58)
at step (SpfxCors.module.scss.ts:17)
at Object.next (SpfxCors.module.scss.ts:17)
at SpfxCors.module.scss.ts:17
at new Promise ()
i tried code which you provided. but it is gives following error message.
TypeError: Failed to fetch
at FetchProvider.UE6e.FetchProvider.fetch (sp-webpart-workbench-assembly_en-us.js:49867)
at Function.8Y7G.HttpClientHelper.fetchCore (sp-webpart-workbench-assembly_en-us.js:48803)
at HttpClient.LJZb.HttpClient._fetch (sp-webpart-workbench-assembly_en-us.js:49488)
at HttpClient.LJZb.HttpClient.fetch (sp-webpart-workbench-assembly_en-us.js:49456)
at HttpClient.LJZb.HttpClient.get (sp-webpart-workbench-assembly_en-us.js:49469)
at SpfxCors. (SpfxCors.tsx:58)
at step (SpfxCors.module.scss.ts:17)
at Object.next (SpfxCors.module.scss.ts:17)
at SpfxCors.module.scss.ts:17
at new Promise ()
but following code is working for same URL
let reqUrl = “https://api.darksky.net/forecast/fe01c49b6533f1d7460ed2e82302b5bc/24.4851589,74.8916458?callback=?&units=si”;
$.getJSON(reqUrl, (data) => {
console.log(“data :”);
console.error(data);
}).catch((jqXHR, textStatus, errorThrown) => {
console.error(textStatus);
console.log(textStatus);
});
thanks
navaratan
LikeLike
You have to use the azure function, I’ll make the video for this and post it this weekend for your better understanding
LikeLike
thanks ravichandra
LikeLike
Hi Ravichandran,
Can we call 3rd party apis (Jira) in spfx without Azure function using httpclient ?
LikeLike
Yes, you can if you not get CORS error
LikeLike