How to use swr with Express #1513
Unanswered
hyphen1370
asked this question in
Q&A
Replies: 1 comment 2 replies
-
SWR is a React Hook, it seems that you're not running it inside a React Component? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am trying to build a react ssr on Azure function for Javascript with express. However, Azure function for Javascript doesn't support any ES6 or above. I have to use es5 syntax. Could I use swr in this environment?
Here is what I tried:
async function getChecklistDate() {
const useSWR = require('swr').useSWR;
const commonFunctions = require('../../components/commonFunctions/CommonFunctions.js');
const { request, gql } = require('graphql-request');
async function getChecklistDate() {
const { data, error } = useSWR(
query backupRestoreChecklistGetCheckDateAllQuarter { backupRestoreChecklistGetCheckDateAllQuarter }
,query => request('/api/graphql', query),
)
console.log(data);
console.log(error);
return "data";
}
when I ran it, it gave me this error:
(node:23177) UnhandledPromiseRejectionWarning: TypeError: useSWR is not a function
Thanks
Beta Was this translation helpful? Give feedback.
All reactions