Response status was 303

I have a problem in fetching the github api using this code and the error show is Response status 301 ‘Moved Permanently’ but redirect mode was set to ‘error’. I’m new on the airtable scripting environment and I don’t quite sure how to make this successful.

let response = await remoteFetchAsync('');
let x = await response.json();

Thank you.

Try redirect : “manual” and see how it behaves.

3XX codes + manual redirects usually lead to “opaque-type” response shenanigans. This partiular case included. AFAIK that’s a dead end in most scenarios; the ‘manual’ mode isn’t too flexible and there’s no way to divulge the new URL while using it (at least from inside the Scripting block). Only cancel the request after getting an empty response object while hoping the cause is server-side and not somewhere in the infinite depths of your browser cache.

Anyway I think I got it to work with a bit of fiddling:

const ghUrl = '';
await remoteFetchAsync(ghUrl)
    .then(response => {
        if(response.ok) console.log(response)
        else if(response.type==='opaqueredirect') console.warn(response.statusText)
        else if(response.redirected) (
            () => {
                return remoteFetchAsync(
                       ghUrl,{redirect: 'manual', mode: 'cors'}
        )})}).catch(err => console.error(`Error: ${err}.\nURL:${ghurl}`));

You haven’t said much about your end goal @Marc_Justin_Rait but is this the page your async requests were trying to reach? Just as I’ve given up on making it work within the constraints of the API, I managed to stumble into a 200 response by hacking away at the url itself (lumerjack-style hacking, not the mr robot variety lol).

1 Like

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.