CORE HTTP
A simple HTTP client.
yarn add @procore/core-http
This simple wrapper over native fetch makes interacting with the Procore API a little easier. By default, it injects a CSRF token from known places when working from inside of an Micro Front End, or in a Hydra Client, but takes in a second parameter that helps you override any value you would need to customize.
Usage
Simple Example
import { request } from '@procore/core-http'
function ExampleRequest() {
request('/some-url-here')
.then((response) => console.log(response))
.catch((err) => console.error(err))
}
With baseUrl option
import { request } from '@procore/core-http'
function ExampleRequest() {
request('/some-url-here', { baseUrl: 'https://www.example.com' })
.then((response) => console.log(response))
.catch((err) => console.error(err))
}
Automatically convert from json response with a text fallback.
import { requestJSON } from '@procore/core-http'
function ExampleRequest() {
requestJSON('/some-url-here.json')
.then((response) => console.log(response))
.catch((err) => console.error(err))
}