Socket
Book a DemoInstallSign in
Socket

@zesty-io/fetch-page

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zesty-io/fetch-page

Fetches relative URL based JSON from a Zesty.io content instance

1.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

fetch-page

NPM Javascript package for fetching JSON data of a Zesty.io CMS page

How to Install

Install from NPM or Yarn

npm install @zesty-io/fetch-page

How to Use

Fetch page requires on the url of the page you're fetching data for and an env value with Zesty Config JSON object. Having access to the URL from window.location.pathname or your routing middle ware is neccesary to feed the function.

Zesty config value in your ENV are a requirement. An Example of the Zesty.io JSON object is below, you may also copy the JSON file from the examples folder. This value must be stringfied when it is saved.

{
  "instance_zuid": "8-xyzxyz-7xyzxy",
  "stage": "https://xyz-dev.webengine.zesty.io",
  "production": "https://www.myproductiondomain.com",
  "stage_password": "",
  "auth": "",
  "src_dir": "",
  "options": {
    "skip_config_overwrite": false,
    "model_ignore_list": ["6-xyz"]
  },
  "runinstaller": true
}

App.js Example

Import fetchPage into your App.js

import React from 'react';
import { fetchPage } from '@zesty-io/fetch-page';

In your App.js function, use setState and useEffect hooks to access the data

import './App.css';
import React from 'react';
import { fetchPage } from '@zesty-io/fetch-page';

function App() {
  const [content, setContent] = React.useState({ title: 'missing'});

  React.useEffect(() => {
    // declare the data fetching function
    const fetchData = async () => {
      setContent(await fetchPage(window.location.pathname));
    }
  
    // call the function
    fetchData();
  }, [])


  return (
    <div className="App">
      {content?.title && <h1>{content.title}</h1>}
    </div>
  );
}

export default App;

Keywords

zesty-io

FAQs

Package last updated on 01 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.