graphql-rest-wrapper icon indicating copy to clipboard operation
graphql-rest-wrapper copied to clipboard

How to? - with authorization header

Open MichelDiz opened this issue 7 years ago • 0 comments

I've got this

const fetchApi = async () => 
      fetch(myApiUrl, {
        method: 'GET',
      headers: {
        'authorization': 'Basic RDJXREIzV0ZETTNIOEJLQUc5VkY1UUNLQ1UyUVhLWjU6',
          'Accept': 'application/json',
          'Content-Type': 'application/json',
          }
    })    
    .then(function(response) {
        if(response.status == 200) return response.json();
        else throw new Error('Parece que ainda não foi!');
    })
    .then(function(res) {
      console.log(res);
  });

This is right?

const wrapper = new gqlRestWrapper(myApiUrl, {
          method: 'GET',
      headers: {
        'authorization': 'Basic RDJXREIzV0ZETTNIOEJLQUc5VkY1UUNLQaSaAdUVhLWjU6',
          'Accept': 'application/json',
          'Content-Type': 'application/json',
          },
    name: 'MyRestAPI',
    generateSchema: true,
    saveSchema: true,
    graphiql: true
})

I'll have to do this on each end point right? I have more then 20 end points

Thanks!

Best Regards.

MichelDiz avatar Jul 20 '17 23:07 MichelDiz