@siren-js/client
Version:
Siren API client library
14 lines (13 loc) • 462 B
JavaScript
import fetch from 'cross-fetch';
import { isHyperlink } from './utils';
/**
* Follows `target` by making an HTTP `GET` request.
* @param target request target
* @param options configuration object
* @returns HTTP response of following `target`
*/
export async function follow(target, options = {}) {
const input = isHyperlink(target) ? target.href : target;
const url = new URL(input, options.baseUrl);
return fetch(url, options.requestInit);
}