Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

byu-api-request

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

byu-api-request

Utility for making a server to server request using BYU's API gateway authentication

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

BYU logo byu-api-request

Utility for making a server to server request using BYU's current API gateway authentication method

codecov

Requires Node 18+

Installation

npm i --save byu-api-request

Usage

This package will automatically generate the host domain to be used based on your environment variables. You need to have a variable named ENVIRONMENT_NAME in you environment variables and have it assigned to one of the following values:

  • prd for Production
  • dev for Sandbox
  • apidev for API Development

Set up with setOauthSettings and then make requests with request

Examples:

const api = require('byu-api-request')

(async () => {
  // Do this once on startup
  await api.setOauthSettings('myClientKey', 'myClientSecret')
  
  // After that, make all the requests you want
  try {
    // Simple GET request
    const response1 = await api.request({ url: `/echo/v1/echo/test` })

    // Request using another method
    const response2 = await api.request({ method: 'PUT', url: `/byuapi/students/v2/123456789/enrolled_classes/Summer2019,BIO,100,001`, body: { credit_hours: 3 } })
    
    // Request that passes along an original JWT
    const response3 = await api.request({ url: `/echo/v1/echo/test` }, 'some original jwt to pass along')
    
    // Request where you want to know what status code came back (instead of just rejecting if it's not 2XX)
    const response4 = await api.request({ url: `/echo/v1/echo/test`, simple: false, resolveWithFullResponse: true })
  } catch (e) {
    console.error(e) // Handle errors
  }
})

For more information on the options you can use for the request function, see fetch.

FAQs

Package last updated on 27 Aug 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc