Adi
Adi
RReactiflux
Created by Adi on 1/23/2023 in #help-threads-react
✅ – Adi – 11-00 Jan 23
I am using this code snippet:
import nocountries from '../data/nocountries.json';
import countryList from "country-list";
import { getSession } from "next-auth";

export default async (req, res) => {
const session = await getSession({ req });
if (!session) {
return res.status(401).send({ Error: 'Unauthenticated User' });
}

if (req.method === 'GET') {
try {
const { country, filter } = req.query;
const code = countryList.getCode(country);

const result = nocountries[code].filter(item => item.target_type === filter);

res.status(200).send(result);
} catch (error) {
console.error("Error: ", error)
res.status(500).send({ message: "Failed" });
}
} else {
res.status(500).send({ message: "Internal Server Error" });
}
}
import nocountries from '../data/nocountries.json';
import countryList from "country-list";
import { getSession } from "next-auth";

export default async (req, res) => {
const session = await getSession({ req });
if (!session) {
return res.status(401).send({ Error: 'Unauthenticated User' });
}

if (req.method === 'GET') {
try {
const { country, filter } = req.query;
const code = countryList.getCode(country);

const result = nocountries[code].filter(item => item.target_type === filter);

res.status(200).send(result);
} catch (error) {
console.error("Error: ", error)
res.status(500).send({ message: "Failed" });
}
} else {
res.status(500).send({ message: "Internal Server Error" });
}
}
I am getting error: getSession) is not a function I used import { getSession } from "next-auth/client"; still it did not work. Any idea what I am missing?
6 replies
RReactiflux
Created by Adi on 8/5/2022 in #help-js
Adi – 19-33 Aug 5
or do you think it is premature optimization?
11 replies
RReactiflux
Created by Adi on 8/5/2022 in #help-js
Adi – 19-33 Aug 5
for first time call it takes 200-300ms but latter it is very fast less than 100ms may be because of caching. I am using $5 droplet server node/express server. Do you think putting that endpoint behind cloudflare CDN worker/functions would be helpful for improving performance?
11 replies
RReactiflux
Created by Adi on 8/5/2022 in #help-js
Adi – 19-33 Aug 5
😅
11 replies
RReactiflux
Created by Adi on 8/5/2022 in #help-js
Adi – 19-33 Aug 5
what should be ideal response time of API call via which I am getting config info
11 replies
RReactiflux
Created by Adi on 8/5/2022 in #help-js
Adi – 19-33 Aug 5
any suggestions?
11 replies
RReactiflux
Created by Adi on 8/5/2022 in #help-js
Adi – 19-33 Aug 5
I am trying to build widget which loads on any website but I want to have customization for widget. That customization is done by user on dashboard page. Customization includes widget color, button color, button text, background color and position. This data is fetched and DOM is updated again. Is there any better way to do this stuff?
11 replies
RReactiflux
Created by Adi on 7/14/2022 in #help-js
✅ – Adi – 17-58 Jul 14
no it cannot thats why passing it as a param
11 replies
RReactiflux
Created by Adi on 7/14/2022 in #help-js
✅ – Adi – 17-58 Jul 14
oh ok
11 replies
RReactiflux
Created by Adi on 6/26/2022 in #help-js
Adi – 09-52 Jun 26
but I have application which already has service worker register file what I am doing is just injecting sw.js file script through nginx. By this -> service worker register file I mean to say code which does registration like this https://github.com/dbrennand/PS2Alert.me/blob/ac569e83efefec2f5e94d4a145a3756b7c6d0ecb/frontend/index.js#L56
5 replies
RReactiflux
Created by Adi on 6/26/2022 in #help-js
Adi – 09-52 Jun 26
for more info: I was able to serve this file (https://github.com/dbrennand/PS2Alert.me/blob/ac569e83efefec2f5e94d4a145a3756b7c6d0ecb/frontend/sw.js#L11) through nginx server as a static file but when I use self.importScripts() it throws error -> importScripts is not a function
5 replies
RReactiflux
Created by Adi on 6/22/2022 in #help-js
✅ – Adi – 08-24 Jun 22
In my case I want to delete subscriptions i.e call delete API when subscription fails. So should I do that in catch block or first collect all the failed subscriptions and then delete them one by one?? what do you suggest?
8 replies