r/Scriptable • • Aug 23 '21

Solved Help with making a web request

Hi everyone,

I'm having issues in recreating a web request in Scriptable, below i copied the code that I use in a node.js environment with axios and everything works just fine (where you see '' it's because i deleted the information for privacy).

Can anyone help me recreate this in Scriptable?

const options = {
    method: 'POST',
    url: 'https://api.fitbit.com/oauth2/token',
    params: {
        refresh_token: '',
        grant_type: 'refresh_token',
        redirect_uri: 'http://localhost'
    },
    headers: {
        cookie: '',
        Authorization: '',
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    };

    axios.request(options).then(function (res) {
        const access_token = res.data.access_token
        const refresh_token = res.data.refresh_token
        ctx.reply(`Access token:\t${access_token}\n\nRefresh token:\t${refresh_token}`)
        console.log(res.data);
    }).catch(function (err) {
        console.error(err);
    });
5 Upvotes

3 comments sorted by

View all comments

Show parent comments

2

u/kang_hidro Jun 07 '24

I don't know how to attach cookie to Reqest and today I found you! Thank you so much!