node-nock/nock#768

node v8.17.0
version: 2.0.0
endpointsharetweet
Reproduceable testcase for https://github.com/node-nock/nock/issues/768
const nock = require('nock'); const axios = require('axios'); const request = require('request') nock('https://api.smartsheet.com/2.0/sheets') .defaultReplyHeaders({ "accept": "application/json, text/plain, */*", "authorization": "Bearer ll352u9jujauoqz4gstvsae05", "user-agent": "axios/0.18.0" }) .get('/') .reply(200, {"data" : "test"}); request({ method: 'get', url: 'https://api.smartsheet.com/2.0/sheets', headers: { "authorization": "Bearer ll352u9jujauoqz4gstvsae05", "user-agent": "axios/0.18.0" }}, (err, res) => { console.log('res', res.body.data) // body is a string }) axios({ method: 'get', url: 'https://api.smartsheet.com/2.0/sheets', headers: { "authorization": "Bearer ll352u9jujauoqz4gstvsae05", "user-agent": "axios/0.18.0" }}).then((res) => { console.log('res', res.data.data) // res.data is JSON object }).catch(er => { console.log(er) })
Loading…

no comments

    sign in to comment