Making Get request to Yammer API works using Postman tool but not with Vue-Resource

I am trying to integrate Yammer API in my Vue.JS project, for Http calls I am using Vue-Resource plugin. While making GET Http call to get posts from Yammer it gives me following error –

Response to preflight request doesn’t pass access control check: No
‘Access-Control-Allow-Origin’ header is present on the requested
resource.

I tried postman tool and that gives successful response, but when I try to run the same thing in my Vue.JS project using Vue-Resource plugin it wont work.

The Vue.JS code snippet –

function(){
            this.$http.get("https://www.yammer.com/api/v1/messages/my_feed.json").then((data)=>{
                console.log(data);
            });

In main.vue file i have –

Vue.http.interceptors.push((request, next) => {
  request.headers.set('Authorization', 'Bearer my_yammer_token')
  request.headers.set('Accept', '*/*')
  next()
})

Then I tried the code snippets provided by Postman tool for jquery, that too not working.

jQuery code –

var settings = {
  "url": "https://www.yammer.com/api/v1/messages/my_feed.json",
  "method": "GET",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer my_yammer_token",
    "Cookie": "yamtrak_id=some_token; _session=some_token"
  },
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

Though, I found similar questions but nothing worked for me.
I am working this to resolve from last 2 days but getting failed again and again. Please guide/help me.

47 thoughts on “Making Get request to Yammer API works using Postman tool but not with Vue-Resource”

Leave a Comment