How do I fetch in Remix JS from a specific (back-end) API link / Database URL? - remix

I am trying to follow the Jokes tutorial #https://remix.run/docs/en/v1/tutorials/jokes
and I was wondering how do I fetch from a specific (back-end) API link / Database URL?
Can you provide an example (where you use Prisma)?
On the webpage it says "You can use any persistence solution you like with Remix; Firebase, Supabase, Airtable, Hasura, Google Spreadsheets, Cloudflare Workers KV, Fauna, a custom PostgreSQL, or even your backend team's REST/GraphQL APIs"
I have set the DATABASE_URL in the .env file to the API link, however I don't know how to continue from here

Please provide some code, so we can help you based on a specific question.
In general, you would fetch data inside your loader function in Remix. That function runs on your server and can be used to fetch from a database or API.
If you have trouble with Prisma, I would suggest you have a look at the tutorial you are following or look at the Prisma documentation.
You can find more information about data loading in Remix in the Remix documentation: https://remix.run/docs/en/v1/guides/data-loading

Related

How to create database for React app and schedule scrapers

I have a question regarding one of my React apps that I recently developed.
It's basically a landing page, which is using React frontend and Node+Express backend and its scraping data from various pages (scrapers are developed in Python).
Right now, the React app itself is hosted in Heroku and the execution of scrapers is working, but not ideally.
What I would like to do is to set up a proper flow
create a database
schedule the scrapers
collect the data in the database
request data from the database in the React app, when needed
I've read about different possibilities such as Firebase, also different AWS options like EC2, Lambda, S3 etc. I'm a bit lost in the midst of all this, so maybe you can help out and give me some suggestions!
Thanks in advance!
If I understood correctly your problem, then the scraping itself does not have to be associated with your landing page/React application. Let's walk through a potential solution.
SQL Database
You can use anything SQL database here, really. Create a table with relevant columns for each source that you will scrape. I personally like RDS Postgres within AWS. Scraping Yahoo Finance? Well, have a table called "yahoo" and columns such as "ticker", "open", "close", "date", etc.
Schedule the scrapers
I assume you already taken care of the actual scraping/extracting information from the source with Python. You can use cronjob or schedule package to schedule the scrapers to run hourly/daily/weekly/etc. Connect your scrapers to the SQL database in order to access it and store the data in whichever way you need. The scrapers can live in EC2 in AWS. You would need to do some setup for the instance. You can also connect scrapers to an application such as Sentry to easily monitor the progress and errors of scraping.
React App
Connect the database to the Node backend. Use a simple API call to your backend to access the data and use it. You can use sequelize ORM to access the Postgres database.
To conclude, I believe the idea is relatively straightforward, you just need to select the tools (I gave some suggestions) and start implementing them!

How do I pass a value into nodeJS from another client-side javascript document?

I'm currently new to node.js, and I am making a chat-bot based application. However, the IBM Natural Language Understanding API does not have documentation for regular javascript code, and instead requires the utilization of the nodeJS server. I had no knowledge of nodeJS beforehand.
The application is intended to work as follows: A user types in a large corpus of text, then the "chatbot" sends the text to FireBase and to a nodeJS module to have main keywords extracted by the IBM API. These main keywords are then stored into Firebase and then extracted from firebase by the web application to display the keyword text. I tried to run node.js, but I cannot seem to pass the variable from the chatBox into nodeJS. I am also using localhost:5000 as a port for my website. Where is my logic flawed, and what is the best way to resolve this issue?

How to implement login authentication to my Vue NodeJS restful API?

I am new to Stackoverflow so please forgive me if my question is bit difficult to understand. However, background of my problem is following.
I have created a NodeJS RESTful API based on the following tutorial -
https://www.codementor.io/olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd
I have also created a Vue based frontend what I use to display data from database with GET request, POST new data to database and also PATCH/DELETE requests.
I need to create a login/registration system to secure my api endpoints so that the unauthorized person cannot see/delete/modify the content but I have no idea where to start or how to implement it.
My project frontend and backend repositories are visible on:
Frontend - https://github.com/umbluu/mufc-api-fe
Backend - https://github.com/umbluu/mufc-api-be
Can someone please point out some hints/tips how to proceed with my task?

Node.js Server and Cognito Sync

I am trying to create a Node.js Server which will pickup data from a local DB and put it to Cognito. I cannot use CognitoSyncManager because this is not a browser app.
Can anyone tell me how can I upload the data?
Also, I am unable to find out how to create dataset and how to upload data to dataset using CognitoSync.
Sorry, I am a newbee to Cognito that is why asking such a basic question.
If you want to use Cognito Sync with AWS Node Js SDK, you will need to use the class CognitoSync instead of CognitoSyncManager. Here's the API reference
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoSync.html
Following blog has a good guide on getting started with Cognito Sync with Node Js
https://mobile.awsblog.com/post/Tx1KD3G8Q9NFWVF/Amazon-Cognito-in-your-Node-js-web-app

Node.js and Parse.com for Dynamic Opengraph tags

I have a JS wep app & Parse.com backend which I would like to hook up to Facebook using Opengraph actions. Problem is being a web app, it's not possible to manipulate the meta tags in such a way so that the Facebook scraper will use it.
Most solutions point to having a server side implementation running alongside your web app. Having read a little about Node.js...I think there could be another way and I was wondering if Node.js experts could shed some light.
Would it be possible to use Node.js to query my Parse.com DB based on URL parameters in order to serve up the proper meta tags? And would it be quick enough a solution?
Something like
- Request comes in - 'xxx.com/user/1234'
- Node queries Parse.com DB with user=1234
- Parse returns the information for meta tags
- Node serves up HTML page with the correct meta tags
- Web app runs as normal
Thanks in advance for contemplating this question.
You can absolutely do this. To set up a simple webserver with node.js, you can follow the simple example on their homepage.
http://nodejs.org/
To communicate with Parse from node.js, you can use the Parse JavaScript SDK, available through through npm.
http://blog.parse.com/2012/10/11/the-javascript-sdk-in-node-js/
https://parse.com/docs/js_guide

Resources