-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server review #7
base: feedback
Are you sure you want to change the base?
Conversation
template for express api
add cors, node-fetch, and get search/query
update fetch data
add axios get to serpstack
server full functional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work again guys, me and Ravil were impressed that you used a public API. Super refreshing as we created one so was nice to see someone take a different approach. Works well, we ran the server side with no issues. Although, probably not your fault, but results took a few seconds to return and show on the page. Other than that great job and was a pleasure too look through and try out 👍
@@ -1 +1,33 @@ | |||
# Gclone Server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great use of README, as mentioned in other repo
@@ -0,0 +1,15 @@ | |||
function formatData(data, length){ | |||
data.length = length | |||
return data.filter(item => item !== 'undefined') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of validation!
|
||
function randomData(data){ | ||
length = data.length | ||
randomIndex = Math.floor(Math.random() * length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of Math functions
@@ -0,0 +1,6 @@ | |||
const server = require("./server"); | |||
const port = process.env.PORT || 3000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of OR rule
axios.get(url) | ||
.then(function (response) { | ||
// formatData(response); | ||
res.status(200).send({body: helpers.formatData(response.data.organic_results, 10)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could be placed into two lines to make it more readable:
const formated = helpers.formatData(response.data.organic_results, 10) res.status(200).send({body: formated)
axios.get(url) | ||
.then(function (response) { | ||
// formatData(response); | ||
res.status(200).send({body: helpers.randomData(helpers.formatData(response.data.organic_results, 10))}) | ||
}) | ||
.catch(console.warn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could create a separate function for fetching response passing through as arguments, the url and the function you want to use to format the data. This would reduce duplicate code!
No description provided.