Skip to content

Simple example api fetcher. This script make periodically requests to api and save result to database

Notifications You must be signed in to change notification settings

alelipona/simple-from-api-to-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-from-api-to-database

Table of Contents

About

Simple example api fetcher app This script make periodically requests to api and save result to database

Getting Started

create collection test - (id,uid,name) with one row:
id - autogenerated,
uid - 1,
name - Rick Sanchez

Installing

git clone https://github.com/alelipona/simple-from-api-to-database.git
cd simple-from-api-to-database
npm install

create file .env with following:

POCKETBASE_HOST=https://your-pockethost-account.pockethost.io
POCKETBASE_USER=your-collection-admin-user
POCKETBASE_PASSWORD=your-collection-admin-password
API_ENDPOINT=https://rickandmortyapi.com/graphql

check if you test pocketbase collection with one row available and then:

node app.js

some from log:

  data: {
    collectionId: 'wfoh8t2zrsm3ub3',
    collectionName: 'test',
    created: '2023-03-24 13:08:44.601Z',
    id: '7mm6cxa025ozd1f',
    name: 'Abadango Cluster Princess',
    uid: 6,
    updated: '2023-03-24 13:08:44.601Z'
  }

Usage

get data from api and save

Releases

No releases published

Packages