redirect after a fetch post call

Request.redirect could be "follow", "error" or "manual".

If it is “follow”, fetch() API follows the redirect response (HTTP
status code = 301,302,303,307,308).

If it is “error”, fetch() API treats the redirect response as an
error.

If it is “manual”, fetch() API doesn’t follow the redirect and returns
an opaque-redirect filtered response which wraps the redirect
response.

Since you want to redirect after a fetch just use it as

fetch(url, { method: 'POST', redirect: 'follow'})
    .then(response => {
        // HTTP 301 response
    })
    .catch(function(err) {
        console.info(err + " url: " + url);
    });

Leave a Comment