4.0.1 • Published 1 year ago

onedrive-fetch v4.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

onedrive-fetch

Fetches and returns children's json data (ex: name and URL) from a public OneDrive folder using the OneDrive API.

Install

$ npm install onedrive-fetch

Usage

The following example returns children (files/folders) in the OneDrive location ".../Root/Folder/Sub-folder".

const odfetch = require("onedrive-fetch");

odfetch("https://1drv.ms/u/s!AsOBq5tE-6XDgZpN9uwZG5iZWGi3vw", //Required OneDrive root folder share URL
        ["Folder", "Sub-folder"]) //Optional array of sub-folder names to open
  .then( //Note this is asynchronous
    function (result) {
      if (result.error) {
        
        //Handle errors
        console.log(result);
      } else {
      
        //Handle successful fetch
        result.forEach((item) => {
          console.log({ name: item.name, url: item.webUrl });
        });
        //FYI: OneDrive API returns an array of child objects
        
        //Example log
        //{ "name": "File 1.jpg", "url": "https://1drv.ms/i/s!AsOBq5tE-6XDgZpQ9uwZG5iZWGi3vw" }
        //{ "name": "File 2.jpg", "url": "https://1drv.ms/i/s!AsOBq5tE-6XDgZpR9uwZG5iZWGi3vw" }
      }
  }
);
4.0.1

1 year ago

4.0.0

1 year ago

3.0.0

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago