{"action":"opened","issue":{"url":"https://api.github.com/repos/axios/axios/issues/1330","repository_url":"https://api.github.com/repos/axios/axios","labels_url":"https://api.github.com/repos/axios/axios/issues/1330/labels{/name}","comments_url":"https://api.github.com/repos/axios/axios/issues/1330/comments","events_url":"https://api.github.com/repos/axios/axios/issues/1330/events","html_url":"https://github.com/axios/axios/issues/1330","id":293897897,"number":1330,"title":"An instance doesn't seem to have CancelToken property","user":{"login":"HamsterCoder","id":2494170,"avatar_url":"https://avatars1.githubusercontent.com/u/2494170?v=4","gravatar_id":"","url":"https://api.github.com/users/HamsterCoder","html_url":"https://github.com/HamsterCoder","followers_url":"https://api.github.com/users/HamsterCoder/followers","following_url":"https://api.github.com/users/HamsterCoder/following{/other_user}","gists_url":"https://api.github.com/users/HamsterCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/HamsterCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HamsterCoder/subscriptions","organizations_url":"https://api.github.com/users/HamsterCoder/orgs","repos_url":"https://api.github.com/users/HamsterCoder/repos","events_url":"https://api.github.com/users/HamsterCoder/events{/privacy}","received_events_url":"https://api.github.com/users/HamsterCoder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-02T14:02:14Z","updated_at":"2018-02-02T14:02:14Z","closed_at":null,"author_association":"NONE","body":"#### An instance doesn't seem to have CancelToken property\r\n\r\nLately I needed to time some of the requests made by axios, so following the documentation I created and interceptor for an instance of axios (since I do not want to affect all axios requests, only specific ones):\r\n\r\n```\r\nvar axios = require('axios').create(); // Create new instance of axios, to use interceptors safely\r\n\r\nfunction setAxiosMeta(config, meta) {\r\n    config.meta = config.meta || {};\r\n\r\n    config.meta = Object.assign(config.meta, meta);\r\n}\r\n\r\nfunction getAxiosMeta(config) {\r\n    config.meta = config.meta || {};\r\n\r\n    return config.meta;\r\n}\r\n\r\naxios.interceptors.request.use(function (config) {\r\n    setAxiosMeta(config, {\r\n        requestStartTime: Date.now()\r\n    });\r\n\r\n    return config;\r\n}, function (error) {\r\n    return Promise.reject(error);\r\n});\r\n\r\naxios.interceptors.response.use(function (response) {\r\n    var meta = getAxiosMeta(response.config);\r\n\r\n    setAxiosMeta(response.config, {\r\n        requestTime: Date.now() - meta.requestStartTime,\r\n        requestId: response.headers['x-yt-request-id'],\r\n        proxy: response.headers['x-yt-proxy']\r\n    });\r\n\r\n    return response;\r\n}, function (error) {\r\n    return Promise.reject(error);\r\n});\r\n```\r\n\r\nWe also use request cancellation:\r\n\r\n```\r\nvar cancellation = axios.CancelToken.source();\r\n```\r\nAnd this line now throws and error:\r\n\r\n```\r\nUncaught TypeError: Cannot read property 'source' of undefined\r\n    at Object.core._createRequestWithCancellation (yt.js:826)\r\n    ....\r\n```\r\n\r\nIs there a known workaround for creating Cancellation when working with and instance of axios? It isn't very clear what an instance is, at least after I encountered this behaviour. At first I thought that instance is the same as axios itself, but can be additionally configured.\r\n\r\n#### Context\r\n\r\n- axios version: *e.g.: v0.17.1*\r\n- Environment: *e.g.: node v8.9.4, chrome 62, ubuntu Xenial*\r\n"}}
{"actor":{"display_login":"HamsterCoder"}}