Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
node-nock/nock#768
node v8.17.0
version:
2.0.0
endpoint
share
tweet
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