import fetch , { RequestInit , Response } from 'node-fetch' ; export async function requestFollowRedirectsWithSameMethodAndBody ( url , options ) { const manualRedirectOptions = { ... options , redirect : 'manual' as RequestRedirect , } ; let response ; for ( let i = 0 ; i < 10 ; i ++ ) { response = await fetch ( url , manualRedirectOptions ) ; if ( response . status >= 300 && response . status < 400 ) { url = response . headers . get ( 'location' ) ; } else { break ; } } return response ; }