使用fetch()对Instagram API发出POST请求,抛出错误

时间:2018-02-14 07:58:18

标签: javascript reactjs facebook instagram-api isomorphic-fetch-api

我正在使用fetch从Instagram API检索授权

的数据

需要访问令牌以响应请求。

但是,得到了错误: {"error_type": "OAuthException", "code": 400, "error_message": "You must provide a client_id"}

const url = 'https://api.instagram.com/oauth/access_token';

let fetchData = {
            method: 'POST', 
            body: JSON.stringify({
              'client_id': 'xxxxxxxxxxxxxxxxxxxxxxx',
              'client_secret': 'xxxxxxxxxxxxxxxxxxxxxxx',
              'grant_type': 'authorization_code',
              'redirect_uri':'http://localhost:3000/',
              'code':'xxxxxxxxxxxxxxxxxxxxx'
            })
}

fetch(url, fetchData)
        .then((response) => {
          console.log(response, "::response")
          return response.json();
        }).catch((error) => {
          console.log(error," :: ERROR");
          return error;
        });

0 个答案:

没有答案
相关问题