-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
315 additions
and
65 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// callback hell example | ||
app.get("/details", function (req, res) { | ||
var name = req.query.name; | ||
console.log(name); | ||
|
||
Scopus.find({ name: name }, | ||
{ '_id': 0, 'authorId': 1 }, | ||
function (err, result) { | ||
if (err) { } | ||
else { | ||
var searchResult = result[0]["authorId"]; | ||
console.log(searchResult); | ||
var options = { | ||
url: "https://api.elsevier.com/content/author/author_id/" | ||
+ searchResult + "?apiKey", | ||
headers: { 'Accept': 'application/json' } | ||
}; | ||
request(options, function (error, response, body) { | ||
if (error) { | ||
|
||
// Print the error if one occurred | ||
console.error('error in Authors :', error); | ||
|
||
// Print the response status code if a response was received | ||
console.log('statusCode:', response && response.statusCode); | ||
res.send("error") | ||
} | ||
else if (!error) { | ||
var jsonObj = JSON.parse(body); | ||
if (jsonObj['author-retrieval-response'] == undefined) { | ||
res.send("No details"); | ||
} | ||
else { | ||
var reqData = jsonObj['author-retrieval-response'][0]; | ||
var authprofile = reqData["author-profile"] | ||
var names = authprofile["preferred-name"]["indexed-name"] | ||
console.log(names); | ||
var citation = reqData["coredata"]["citation-count"]; | ||
var query = { authorId: searchResult }; | ||
|
||
Scopus.findOneAndUpdate(query, { | ||
name: names, | ||
citationCount: citation | ||
}, function (err, doc, res) { | ||
if (err) { | ||
console.log("error"); | ||
} | ||
else { | ||
console.log("success"); | ||
} | ||
}) | ||
res.render("details", { data: reqData }); | ||
} | ||
} | ||
}); | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useState } from 'react' | ||
import { Button } from '@mui/material' | ||
import reactLogo from '@/assets/react.svg' | ||
import '@/App.css' | ||
|
||
function App() { | ||
const [count, setCount] = useState(0) | ||
|
||
return ( | ||
<div className="App"> | ||
<div> | ||
<a href="https://vitejs.dev" target="_blank"> | ||
<img src="/vite.svg" className="logo" alt="Vite logo" /> | ||
</a> | ||
<a href="https://reactjs.org" target="_blank"> | ||
<img src={reactLogo} className="logo react" alt="React logo" /> | ||
</a> | ||
</div> | ||
<h1>Vite + React + Redux + RTK + Rect-router + Typescript + MUI 5</h1> | ||
<Button color="secondary">Secondary</Button> | ||
<Button variant="contained" color="success"> | ||
Success | ||
</Button> | ||
<Button variant="outlined" color="error"> | ||
Error | ||
</Button> | ||
<div className="card"> | ||
<button onClick={() => setCount(count => count + 1)}> | ||
count is {count} | ||
</button> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to test HMR | ||
</p> | ||
</div> | ||
<p className="read-the-docs"> | ||
Click on the Vite and React logos to learn more | ||
</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.